/// <summary> /// Initializes a new instance of the <see cref="OAuth"/> class. /// </summary> /// <param name="consumerCredential"> /// The consumer credential. /// </param> /// <param name="serviceProviderDescription"> /// The service provider description. /// </param> /// <param name="signatureMethod"> /// The signature method. /// </param> /// <exception cref="ArgumentNullException"> /// </exception> public OAuth(ConsumerCredential consumerCredential, ServiceProviderDescription serviceProviderDescription, SignatureMethod signatureMethod = SignatureMethod.HmacSha1) { if (consumerCredential == null) { throw new ArgumentNullException("consumerCredential"); } if (serviceProviderDescription == null) { throw new ArgumentNullException("serviceProviderDescription"); } this._Realm = String.Empty; this._ConsumerCredential = consumerCredential; this._SignatureMethod = signatureMethod; this._ServiceProviderDescription = serviceProviderDescription; this.LogEnabled = false; this.LogIndentSize = 4; this.UserAgent = "Mirai"; }
private TwitterApi(string consumerKey, string consumerSecret, string accessToken, string tokenSecret, TokenType tokenType, ApiVersion apiVersion = ApiVersion.V1) { var consumerCredential = new ConsumerCredential(consumerKey, consumerSecret); consumerCredential.SetToken(accessToken, tokenSecret, tokenType); var serviceProviderDescription = new ServiceProviderDescription( new OAuthEndPoint("https://api.twitter.com/oauth/request_token"), new OAuthEndPoint("https://api.twitter.com/oauth/authorize", HttpMethod.Get), new OAuthEndPoint("https://api.twitter.com/oauth/access_token"), ProtocolVersion.V10A); this._OAuth = new OAuth(consumerCredential, serviceProviderDescription); this._OAuth.Realm = ApiBaseUri; this._OAuth.Proxy = null; this.ApiVersion = apiVersion; this._Configuration = new TwitterConfiguration(); this._Timer = new Timer(_ => { var newConfig = this.RetrieveConfiguration(); if (newConfig != null) Interlocked.Exchange(ref this._Configuration, newConfig); }, null, 1000, 1000 * 3600 * 24); }