private void DefaultInit() { this.SignatureMethod = SignatureMethods.HMACSHA1; this.Timestamp = OAuthUtility.GetTimeStamp(); this.Nonce = OAuthUtility.GetRandomKey(); this.Version = "1.0"; }
/// <summary> /// Gets the access token from the remote server. /// </summary> protected override void GetAccessToken() { base.GetAccessToken(); this.Authorization.Parameters.Remove("oauth_signature"); this.Authorization["oauth_nonce"] = OAuthUtility.GetRandomKey(); this.Authorization["oauth_timestamp"] = OAuthUtility.GetTimeStamp(); this.Authorization["oauth_verifier"] = this.AuthorizationCode; this.Authorization["oauth_token"] = this.RequestToken.OAuthToken; this.Authorization.SetSignature ( "POST", new Uri(this.AccessTokenUrl), this.ApplicationSecret, this.Authorization["oauth_token"].ToString(), null ); base.AccessToken = new OAuthAccessToken ( OAuthUtility.ExecuteRequest ( "POST", this.AccessTokenUrl, null, this.Authorization.ToString() ) ); this.Authorization.Parameters.Remove("oauth_verifier"); }
/// <summary> /// Initializes a new instance of the <see cref="OAuthClient"/> class. /// </summary> /// <param name="requestTokenUrl">The address for the request token.</param> /// <param name="authorizeUrl">The address for login.</param> /// <param name="accessTokenUrl">The address for the access token.</param> /// <param name="consumerKey">The application identifier.</param> /// <param name="consumerSecret">The application secret key.</param> /// <param name="signatureMethod">The name of hashing algorithm to calculate the signature: HMAC-SHA1 (default) or PLAINTEXT.</param> /// <exception cref="ArgumentNullException">The <paramref name="requestTokenUrl"/> is null or empty.</exception> public OAuthClient(string requestTokenUrl, string authorizeUrl, string accessTokenUrl, string consumerKey, string consumerSecret, string signatureMethod = SignatureMethods.HMACSHA1) : base(authorizeUrl, accessTokenUrl, consumerKey, consumerSecret) { if (String.IsNullOrEmpty(requestTokenUrl)) { throw new ArgumentNullException("requestTokenUrl"); } this.RequestTokenUrl = requestTokenUrl; this.Authorization["oauth_consumer_key"] = consumerKey; this.Authorization["oauth_nonce"] = OAuthUtility.GetRandomKey(); this.Authorization["oauth_signature"] = ""; this.Authorization["oauth_signature_method"] = signatureMethod; this.Authorization["oauth_timestamp"] = OAuthUtility.GetTimeStamp(); this.Authorization["oauth_token"] = ""; this.Authorization["oauth_version"] = "1.0"; }
/// <summary> /// Updates the nonce and the timestamp. /// </summary> internal void UpdateStamp() { this.Nonce = OAuthUtility.GetRandomKey(); this.Timestamp = OAuthUtility.GetTimeStamp(); }
/// <summary> /// Updates the nonce and timestamp. /// </summary> private void UpdateStamp() { this.Authorization["oauth_nonce"] = OAuthUtility.GetRandomKey(); this.Authorization["oauth_timestamp"] = OAuthUtility.GetTimeStamp(); }