コード例 #1
0
        /// <summary>
        /// Gets a request token from the provider. After acquiring a request token, the user should be redirected
        /// to the website of the provider for approving the application. If successful, the user will be redirected
        /// back to the specified callback URL where you then can exchange the request token for an access token.
        /// </summary>
        /// <returns>An instance of <see cref="SocialOAuthRequestTokenResponse"/> representing the response.</returns>
        public virtual SocialOAuthRequestTokenResponse GetRequestToken()
        {
            // Make the call to the API/provider
            SocialHttpResponse response = GetRequestTokenResponse();

            // Parse the response body
            SocialOAuthRequestToken body = SocialOAuthRequestToken.Parse(this, response.Body);

            // Parse the response
            return(SocialOAuthRequestTokenResponse.ParseResponse(response, body));
        }
コード例 #2
0
        public ActionResult LinkTwitter()
        {
            string rootUrl = Request.Url.GetLeftPart(UriPartial.Authority);

            TwitterOAuthClient client = new TwitterOAuthClient();

            client.ConsumerKey    = WebConfigurationManager.AppSettings["twitterConsumerKey"];
            client.ConsumerSecret = WebConfigurationManager.AppSettings["twitterConsumerSecret"];
            client.Callback       = rootUrl + "/umbraco/surface/Profile/LinkTwitter";

            // Make the request to the Twitter API to get a request token
            SocialOAuthRequestTokenResponse response = client.GetRequestToken();

            // Get the request token from the response body
            TwitterOAuthRequestToken requestToken = (TwitterOAuthRequestToken)response.Body;

            // Save the token information to the session so we can grab it later
            Session[requestToken.Token] = requestToken;

            // Redirect the user to the authentication page at Twitter.com
            return(Redirect(requestToken.AuthorizeUrl));
        }