コード例 #1
0
        // The code in this method is heavily borrowed from the LinkedIn.NET's LNTest "authenticate" method (DlgExample.cs)
        protected void Authenticate()
        {
            if (linkedInClient != null)
            {
                var options = new LinkedInAuthorizationOptions
                {
                    RedirectUrl = REDIRECT_URL,
                    Permissions = LinkedInPermissions.Connections | LinkedInPermissions.ContactsInfo |
                                  LinkedInPermissions.EmailAddress | LinkedInPermissions.FullProfile |
                                  LinkedInPermissions.GroupDiscussions | LinkedInPermissions.Messages |
                                  LinkedInPermissions.Updates,
                    State = STATE
                };

                //create new instance of authorization dialog using authorization link built by _Client
                var dlgAuth = new DlgAuthorization(linkedInClient.GetAuthorizationUrl(options));

                if (dlgAuth.ShowDialog(this) == DialogResult.OK)
                {
                    //get access token using authorization code received
                    var response = linkedInClient.GetAccessToken(dlgAuth.AuthorizationCode, REDIRECT_URL);

                    if (response.Result != null && response.Status == LinkedInResponseStatus.OK)
                    {
                        accessToken = response.Result.AccessToken;
                        SaveConfiguration();
                    }
                }
                else
                {
                    //show error information
                    MessageBox.Show(dlgAuth.OauthErrorDescription, dlgAuth.OauthError);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Get Linkedin URL
 /// </summary>
 /// <returns></returns>
 public string GetAuthorizationUrl()
 {
     return(linkedIn.GetAuthorizationUrl(new LinkedInAuthorizationOptions {
         RedirectUrl = WebConfigurationManagement.LinkedinRedirect_uri, State = Guid.NewGuid().ToString(), Permissions = LinkedInPermissions.EmailAddress
     }));
 }