当前位置: 首页>>代码示例>>C#>>正文


C# Flickr.AuthGetToken方法代码示例

本文整理汇总了C#中FlickrNet.Flickr.AuthGetToken方法的典型用法代码示例。如果您正苦于以下问题:C# Flickr.AuthGetToken方法的具体用法?C# Flickr.AuthGetToken怎么用?C# Flickr.AuthGetToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlickrNet.Flickr的用法示例。


在下文中一共展示了Flickr.AuthGetToken方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Login

        public void Login()
        {
            // Create Flickr instance
            m_flickr = new Flickr(API_KEY, SECRET);

            m_frob = m_flickr.AuthGetFrob();

            string flickrUrl = m_flickr.AuthCalcUrl(m_frob, AuthLevel.Write);

            // The following line will load the URL in the users default browser.
            System.Diagnostics.Process.Start(flickrUrl);

            bool bIsAuthorized = false;
            m_auth = new Auth();

            // do nothing until flickr authorizes.
            while (!bIsAuthorized)
            {
                try
                {
                    m_auth = m_flickr.AuthGetToken(m_frob);
                    m_flickr.AuthToken = m_auth.Token;
                    bIsAuthorized = true;
                }
                catch (FlickrException ex)
                {
                    //TODO
                    string s = ex.Message;
                }
            }
        }
开发者ID:hugoeng,项目名称:test1,代码行数:31,代码来源:FlickrAddon.cs

示例2: buttonStart_Click

 private void buttonStart_Click(object sender, EventArgs e)
 {
     // Create Flickr instance
     Flickr flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
     try
     {
         // use the temporary Frob to get the authentication
         Auth auth = flickr.AuthGetToken(Program.tempFrob);
         // Store this Token for later usage,
         // or set your Flickr instance to use it.
         string info = "Authentification réussie\n" +
             "Utilisateur identifié: " + auth.User.UserName + "\n" +
             "L'identifiant pour cette session est " + auth.Token + "\n";
         Program.AuthToken = auth.Token;
         Program.Username = auth.User.UserName;
         MessageBox.Show(info, "Identification Flickr",
           MessageBoxButtons.OK, MessageBoxIcon.Information);
         Program.WriteConfig();
         Hide();
         var main_window = new MainForm();
         main_window.Show();
     }
     catch (FlickrException ex)
     {
         // If user did not authenticate your application
         // then a FlickrException will be thrown.
         string info = "L'authentification a échoué:\n" + ex.Message;
         MessageBox.Show(info, "Identification Flickr",
           MessageBoxButtons.OK, MessageBoxIcon.Error);
         // Quit application
         Application.Exit();
     }
 }
开发者ID:remyoudompheng,项目名称:flickrstats,代码行数:33,代码来源:DialogAuth.cs

示例3: Step2Button_Click

        private void Step2Button_Click(object sender, EventArgs e)
        {
            Flickr flickr = new Flickr(ApiKey.Text, SharedSecret.Text);

            try
            {
                Auth auth = flickr.AuthGetToken(Frob);
                OutputTextbox.Text += "User Authenticated = " + auth.User.UserName + "\r\n";
                OutputTextbox.Text += "Auth Token = " + auth.Token + "\r\n";

                AuthToken.Text = auth.Token;
            }
            catch (FlickrException ex)
            {
                OutputTextbox.Text += "Authentication failed : " + ex.Message + "\r\n";
            }

            Step1Button.Enabled = true;
            Step2Button.Enabled = false;
            Step3Button.Enabled = false;
        }
开发者ID:kenpower,项目名称:flickdownloader,代码行数:21,代码来源:AuthenticationForm.cs

示例4: CompleteAuthentication

 public static void CompleteAuthentication()
 {
     Flickr flickr = new Flickr(ApiKey, SharedSecret);
     try
     {
         Auth auth = flickr.AuthGetToken(frob);
         authStatus = "SUCCESS";
         authenticatedUsername = auth.User.Username;
         authToken = auth.Token;
         successMessage = "Authentication Successful!";
     }
     catch (FlickrException ex)
     {
         authStatus = "FAILED";
         authenticatedUsername = "";
         authToken = "";
         if (ex.Message == "Invalid frob (108)")
             errorMessage = ex.Message + " Did you give the app permission?";
         else
             errorMessage = ex.Message;
     }
 }
开发者ID:adamlamers,项目名称:Clipboard-Manager,代码行数:22,代码来源:FlickrManager.cs

示例5: ButtonOKClick

        void ButtonOKClick(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(flickrFrob))
            {
                Flickr flickr = new Flickr(FlickrUtils.Flickr_API_KEY, FlickrUtils.Flickr_SHARED_SECRET);

                try
                {
                    Auth auth = flickr.AuthGetToken(flickrFrob);

                    textBoxAuthToken.Text = auth.Token;
                    this.DialogResult = DialogResult.OK;
                }
                catch (FlickrException ex)
                {
                    MessageBox.Show("Authentication failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }
        }
开发者ID:ploufs,项目名称:Greenshot-Flickr-Plugin,代码行数:23,代码来源:SettingsForm.cs

示例6: buttonAuthenticate_Click

        private void buttonAuthenticate_Click(object sender, EventArgs e)
        {
            Flickr flickr = new Flickr(FlickrUtils.Flickr_API_KEY, FlickrUtils.Flickr_SHARED_SECRET);

            if (string.IsNullOrEmpty(flickrFrob))
            {
                flickrFrob = flickr.AuthGetFrob();
                string url = flickr.AuthCalcUrl(flickrFrob, AuthLevel.Write);
                System.Diagnostics.Process.Start(url);
            }
            else
            {
                flickrFrob = string.Empty;
                Auth auth = flickr.AuthGetToken(flickrFrob);
                textBoxAuthToken.Text = auth.Token;
            }
        }
开发者ID:ploufs,项目名称:Greenshot-Flickr-Plugin,代码行数:17,代码来源:SettingsForm.cs

示例7: FlickrGetToken

        private string FlickrGetToken()
        {
            try
            {
                Flickr f = new Flickr(Properties.Settings.Default.FlickrApiKey, Properties.Settings.Default.FlickrShared);
                f.Proxy = GetProxy(true);

                string Frob = f.AuthGetFrob();
                string url = f.AuthCalcUrl(Frob, AuthLevel.Read | AuthLevel.Write | AuthLevel.Delete);
                System.Diagnostics.Process.Start(url);

                if (messages_level==MessagesLevel.MessagesNone || MessageBox.Show("Please confirm that you've authorized FlickrSync to access your flickr account", "Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    Auth auth = f.AuthGetToken(Frob);
                    Properties.Settings.Default.FlickrToken = auth.Token;
                    SaveConfig();
                    return Properties.Settings.Default.FlickrToken;
                }
            }
            catch (Exception e)
            {
                if (Properties.Settings.Default.FlickrToken == "")
                    Error("Unable to obtain Flickr Token", e, ErrorType.Connect);
                else
                    Error("Error obtaining Flickr Token", e, ErrorType.Normal);
            }

            return "";
        }
开发者ID:udif,项目名称:FlickrSync,代码行数:29,代码来源:FlickrSync.cs

示例8: CompleteAuthButton_Click

 private void CompleteAuthButton_Click(object sender, EventArgs e)
 {
     // Create Flickr instance
     Flickr flickr = new Flickr(Program.FlickrAPIKey, Program.FlickrSharedSecretKey);
     try {
         // use the temporary Frob to get the authentication
         Auth auth = flickr.AuthGetToken(tempFrob);
         // Store this Token for later usage,
         // or set your Flickr instance to use it.
         System.Windows.Forms.MessageBox.Show("User authenticated successfully");
         Terminals.Logging.Log.Info("User authenticated successfully. Authentication token is " + auth.Token + ".User id is " + auth.User.UserId + ", username is" + auth.User.Username);
         flickr.AuthToken = auth.Token;
         Settings.FlickrToken = auth.Token;
     } catch(FlickrException ex) {
         // If user did not authenticat your application
         // then a FlickrException will be thrown.
         Terminals.Logging.Log.Info("User not authenticated successfully", ex);
         System.Windows.Forms.MessageBox.Show("User did not authenticate you" +ex.Message);
     }
 }
开发者ID:DefStevo,项目名称:defstevo-collection,代码行数:20,代码来源:OptionsForm.cs


注:本文中的FlickrNet.Flickr.AuthGetToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。