Пример #1
0
        public string LinkedInAuth()
        {
            string email = "";
            try
            {
                oAuthLinkedIn _oauth = new oAuthLinkedIn();
                string oauth_token = Request.QueryString["oauth_token"];
                string oauth_verifier = Request.QueryString["oauth_verifier"];

                if (oauth_token != null && oauth_verifier != null)
                {
                    Application["oauth_token"] = oauth_token;
                    Application["oauth_verifier"] = oauth_verifier;
                    _oauth.Token = oauth_token;
                    _oauth.TokenSecret = Application["reuqestTokenSecret"].ToString();
                    _oauth.Verifier = oauth_verifier;
                    _oauth.AccessTokenGet(oauth_token);

                    string emailResponse = _oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/people/~/email-address", null);
                    email = ParselinkedInXMl(emailResponse, "<email-address>", "</email-address>");
                    string nameResponse = _oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/people/~", null);
                    FirstName = ParselinkedInXMl(nameResponse, "<first-name>", "</first-name>");
                    LastName = ParselinkedInXMl(nameResponse, "<last-name>", "</last-name>");
                    lblAlertMsg.Text = email + " sucessfully Login with LinkedIn" + FirstName + "  " + LastName;
                    Session.Remove(SessionKeys.ServiceProvider);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
            return email;
        }
Пример #2
0
        protected void imgBtnLinkedIn_Click(object sender, ImageClickEventArgs e)
        {
            oAuthLinkedIn _oauth = new oAuthLinkedIn();
            string authLink = _oauth.AuthorizationLinkGet();
            try
            {
                Session[SessionKeys.ServiceProvider] = "LinkedIn";

                if (_oauth.Token != null && _oauth.TokenSecret != null && _oauth.Token.Length > 0 && _oauth.TokenSecret.Length > 0)
                {
                    Application["reuqestToken"] = _oauth.Token;
                    Application["reuqestTokenSecret"] = _oauth.TokenSecret;
                    Application["oauthLink"] = authLink;
                }
                else
                {
                    lblAlertMsg.Text = " LinkedIn keys Not Provided";
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
            if (authLink != null)
            {
                Response.Redirect(authLink);
            }
        }