public CloudPTClient(string consumerKey, string secret, string authToken, string authSecret, AccessRestrictions accessMode) { _consumerKey = consumerKey; _consumerSecret = secret; Restrictions = accessMode; InitializeRestClients(); AuthenticationToken = new AuthToken(authToken, authSecret); }
public string GetOAuthAuthorizeUrl(AuthToken token) { return _reqBuilder.BuildOAuthAuthorizeUrl(token.Token); }
private AuthToken ParseToken(string p) { AuthToken token = new AuthToken(); foreach (string s in p.Split('&')) { var urlParam = s.Split('='); if (urlParam[0] == "oauth_token") token.Token = urlParam[1]; if (urlParam[0] == "oauth_token_secret") token.Secret = urlParam[1]; } return token; }
public AuthToken GetAccessToken(AuthToken token, string pin) { _apiRestClient.Authenticator = RestSharp.Authenticators.OAuth1Authenticator.ForAccessToken(_consumerKey, _consumerSecret, token.Token, token.Secret, pin); RestRequest request = _reqBuilder.BuildOAuthAccessTokenRequest(); IRestResponse response = _apiRestClient.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) throw new CloudPTNetException(); //Wrong PIN if (response.StatusCode != System.Net.HttpStatusCode.OK) throw new CloudPTNetException(); AuthenticationToken = ParseToken(response.Content); return _authToken; }