ExpireRequestTokenAndStoreNewAccessToken() public method

Deletes a request token and its associated secret and stores a new access token and secret.

Any scope of granted privileges associated with the request token from the original call to StoreNewRequestToken should be carried over to the new Access Token.

To associate a user account with the new access token, HttpContext.Current.User may be useful in an ASP.NET web application within the implementation of this method. Alternatively you may store the access token here without associating with a user account, and wait until WebConsumer.ProcessUserAuthorization() or DesktopConsumer.ProcessUserAuthorization(string, string) return the access token to associate the access token with a user account at that point.

public ExpireRequestTokenAndStoreNewAccessToken ( string consumerKey, string requestToken, string accessToken, string accessTokenSecret ) : void
consumerKey string The Consumer that is exchanging its request token for an access token.
requestToken string The Consumer's request token that should be deleted/expired.
accessToken string The new access token that is being issued to the Consumer.
accessTokenSecret string The secret associated with the newly issued access token.
return void
示例#1
0
        /// <summary>
        /// Creates a 23 API service repository, that doesn't require further authentication. Account must be "privileged"
        /// </summary>
        /// <param name="consumerDomain">Domain name</param>
        /// <param name="consumerKey">Consumer key</param>
        /// <param name="consumerSecret">Consumer secret</param>
        /// <param name="accessToken">Access token</param>
        /// <param name="accessTokenSecret">Access token secret</param>
        public ApiProvider(string consumerDomain, string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, bool httpSecure)
        {
            // Save the authentication keys
            _consumerDomain = consumerDomain;

            _consumerKey = consumerKey;
            _consumerSecret = consumerSecret;

            _httpSecure = httpSecure;

            string protocol = httpSecure ? "https://" : "http://";

            // Adjust timeout for requests to the domain to allow for large file uploads
            WebRequest.RegisterPrefix(protocol + _consumerDomain, TwentyThreeCreatorRequestCreator.TwentyThreeHttp);

            // Open the OAuth consumer connection
            _oAuthProviderDescription.AccessTokenEndpoint = new MessageReceivingEndpoint(protocol + "api.visualplatform.net/oauth/access_token", HttpDeliveryMethods.GetRequest);
            _oAuthProviderDescription.RequestTokenEndpoint = new MessageReceivingEndpoint(protocol + "api.visualplatform.net/oauth/request_token", HttpDeliveryMethods.GetRequest);
            _oAuthProviderDescription.ProtocolVersion = ProtocolVersion.V10a;
            _oAuthProviderDescription.UserAuthorizationEndpoint = new MessageReceivingEndpoint(protocol + "api.visualplatform.net/oauth/authorize", HttpDeliveryMethods.GetRequest);
            _oAuthProviderDescription.TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() };

            _oAuthTokenManager = new InMemoryTokenManager(_consumerKey, _consumerSecret);

            _oAuthConsumer = new WebConsumer(_oAuthProviderDescription, _oAuthTokenManager);

            if (accessToken != null)
            {
                _accessToken = accessToken;
                _accessTokenSecret = accessTokenSecret;

                _oAuthTokenManager.ExpireRequestTokenAndStoreNewAccessToken(_consumerKey, "", _accessToken, _accessTokenSecret);
            }

            _oAuthConsumer.Channel.AssertBoundary();
        }
        /// <summary>
        /// Creates a 23 API service repository, that doesn't require further authentication. Account must be "privileged"
        /// </summary>
        /// <param name="consumerDomain">Domain name</param>
        /// <param name="consumerKey">Consumer key</param>
        /// <param name="consumerSecret">Consumer secret</param>
        /// <param name="accessToken">Access token</param>
        /// <param name="accessTokenSecret">Access token secret</param>
        public ApiProvider(string consumerDomain, string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            // Save the authentication keys
            _consumerDomain = consumerDomain;

            _consumerKey = consumerKey;
            _consumerSecret = consumerSecret;

            // Open the OAuth consumer connection
            _oAuthProviderDescription.AccessTokenEndpoint = new MessageReceivingEndpoint("http://api.visualplatform.net/oauth/access_token", HttpDeliveryMethods.GetRequest);
            _oAuthProviderDescription.RequestTokenEndpoint = new MessageReceivingEndpoint("http://api.visualplatform.net/oauth/request_token", HttpDeliveryMethods.GetRequest);
            _oAuthProviderDescription.ProtocolVersion = ProtocolVersion.V10a;
            _oAuthProviderDescription.UserAuthorizationEndpoint = new MessageReceivingEndpoint("http://api.visualplatform.net/oauth/authorize", HttpDeliveryMethods.GetRequest);
            _oAuthProviderDescription.TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() };

            _oAuthTokenManager = new InMemoryTokenManager(_consumerKey, _consumerSecret);

            _oAuthConsumer = new WebConsumer(_oAuthProviderDescription, _oAuthTokenManager);

            if (accessToken != null)
            {
                _accessToken = accessToken;
                _accessTokenSecret = accessTokenSecret;

                _oAuthTokenManager.ExpireRequestTokenAndStoreNewAccessToken(_consumerKey, "", _accessToken, _accessTokenSecret);
            }

            _oAuthConsumer.Channel.AssertBoundary();
        }