public IEnumerable <IOAuthQueryParameter> GenerateApplicationParameters( IReadOnlyConsumerCredentials temporaryCredentials, IAuthenticationRequest authRequest = null, IEnumerable <IOAuthQueryParameter> additionalParameters = null) { var headers = GenerateConsumerParameters(temporaryCredentials).ToList(); // Add Header for authenticated connection to a Twitter Application if (authRequest != null && !string.IsNullOrEmpty(authRequest.AuthorizationKey) && !string.IsNullOrEmpty(authRequest.AuthorizationSecret)) { headers.Add(new OAuthQueryParameter("oauth_token", StringFormater.UrlEncode(authRequest.AuthorizationKey), true, true, false)); headers.Add(new OAuthQueryParameter("oauth_token_secret", StringFormater.UrlEncode(authRequest.AuthorizationSecret), false, false, true)); } else { headers.Add(new OAuthQueryParameter("oauth_token", "", false, false, true)); } if (additionalParameters != null) { headers.AddRange(additionalParameters); } return(headers); }
public static string GetBearerTokenAuthorizationHeader(IReadOnlyConsumerCredentials credentials) { var concatenatedCredentials = StringFormater.UrlEncode(credentials.ConsumerKey) + ":" + StringFormater.UrlEncode(credentials.ConsumerSecret); var credBytes = Encoding.UTF8.GetBytes(concatenatedCredentials); var base64Credentials = Convert.ToBase64String(credBytes); return("Basic " + base64Credentials); }
public static string CreateHash(IReadOnlyConsumerCredentials credentials) { if (credentials is IReadOnlyTwitterCredentials twitterCredentials) { return(CreateHash(twitterCredentials)); } return($"{credentials.ConsumerKey} - {credentials.ConsumerSecret} - {credentials.BearerToken}"); }
public TwitterCredentials(IReadOnlyConsumerCredentials source) { if (source == null) { return; } ConsumerKey = source.ConsumerKey; ConsumerSecret = source.ConsumerSecret; BearerToken = source.BearerToken; }
public static string CreateHash(IReadOnlyConsumerCredentials credentials) { var hash = $"{credentials.ConsumerKey} - {credentials.ConsumerSecret} - {credentials.BearerToken}"; var twitterCredentials = credentials as IReadOnlyTwitterCredentials; if (twitterCredentials == null) { return(hash); } return($"{hash} - {twitterCredentials.AccessToken} - {twitterCredentials.AccessTokenSecret}"); }
private static IEnumerable <IOAuthQueryParameter> GenerateConsumerParameters(IReadOnlyConsumerCredentials consumerCredentials) { var consumerHeaders = new List <IOAuthQueryParameter>(); // Add Header for every connection to a Twitter Application if (consumerCredentials != null && !string.IsNullOrEmpty(consumerCredentials.ConsumerKey) && !string.IsNullOrEmpty(consumerCredentials.ConsumerSecret)) { consumerHeaders.Add(new OAuthQueryParameter("oauth_consumer_key", StringFormater.UrlEncode(consumerCredentials.ConsumerKey), true, true, false)); consumerHeaders.Add(new OAuthQueryParameter("oauth_consumer_secret", StringFormater.UrlEncode(consumerCredentials.ConsumerSecret), false, false, true)); } return(consumerHeaders); }
public ConsumerOnlyCredentials(IReadOnlyConsumerCredentials creds) { ConsumerKey = creds?.ConsumerKey; ConsumerSecret = creds?.ConsumerSecret; BearerToken = creds?.BearerToken; }
public ReadOnlyTwitterCredentials(IReadOnlyConsumerCredentials source) : base(source) { }
public ReadOnlyTwitterCredentials(IReadOnlyConsumerCredentials consumerCredentials, string accessToken, string accessTokenSecret) : base(consumerCredentials) { AccessToken = accessToken; AccessTokenSecret = accessTokenSecret; }
public TwitterInvalidCredentialsException(IReadOnlyConsumerCredentials credentials) : base("The consumer key and consumer secret must be defined!") { Credentials = credentials; }
public ReadOnlyConsumerCredentials(IReadOnlyConsumerCredentials source) { ConsumerKey = source?.ConsumerKey; ConsumerSecret = source?.ConsumerSecret; BearerToken = source?.BearerToken; }
public TwitterCredentials(IReadOnlyConsumerCredentials credentials) : base(credentials) { }