private VerifyCredentialsResult VerifyCredentials(AccessTokenResult accessTokenResult) { if (accessTokenResult == null) { throw new ArgumentNullException("accessTokenResult"); } if (string.IsNullOrEmpty(accessTokenResult.AccessToken)) { throw new ArgumentException("accessTokenResult.AccessToken"); } if (string.IsNullOrEmpty(accessTokenResult.AccessTokenSecret)) { throw new ArgumentException("accessTokenResult.AccessTokenSecret"); } IRestResponse <VerifyCredentialsResult> response; try { var restClient = _restClientFactory.CreateRestClient(BaseUrl); restClient.Authenticator = OAuth1Authenticator.ForProtectedResource(_consumerKey, _consumerSecret, accessTokenResult.AccessToken, accessTokenResult.AccessTokenSecret); var request = new RestRequest("1.0/user"); var responsex = restClient.Execute(request); } catch (Exception exception) { throw new AuthenticationException( "Failed to retrieve VerifyCredentials json data from the Twitter Api.", exception); } //if (response == null || // response.StatusCode != HttpStatusCode.OK || // response.Data == null) //{ // throw new AuthenticationException( // string.Format( // "Failed to retrieve VerifyCredentials json data OR the the response was not an HTTP Status 200 OK. Response Status: {0}. Response Description: {1}", // response == null ? "-- null response --" : response.StatusCode.ToString(), // response == null ? string.Empty : response.StatusDescription)); //} //return response.Data; return(null); }
private VerifyCredentialsResult VerifyCredentials(AccessTokenResult accessTokenResult) { if (accessTokenResult == null) { throw new ArgumentNullException("accessTokenResult"); } if (string.IsNullOrEmpty(accessTokenResult.AccessToken)) { throw new ArgumentException("accessTokenResult.AccessToken"); } if (string.IsNullOrEmpty(accessTokenResult.AccessTokenSecret)) { throw new ArgumentException("accessTokenResult.AccessTokenSecret"); } IRestResponse<VerifyCredentialsResult> response; try { var restClient = _restClientFactory.CreateRestClient(BaseUrl); restClient.Authenticator = OAuth1Authenticator.ForProtectedResource(_consumerKey, _consumerSecret, accessTokenResult.AccessToken, accessTokenResult.AccessTokenSecret); var request = new RestRequest("1.0/user"); var responsex = restClient.Execute(request); } catch (Exception exception) { throw new AuthenticationException( "Failed to retrieve VerifyCredentials json data from the Twitter Api.", exception); } //if (response == null || // response.StatusCode != HttpStatusCode.OK || // response.Data == null) //{ // throw new AuthenticationException( // string.Format( // "Failed to retrieve VerifyCredentials json data OR the the response was not an HTTP Status 200 OK. Response Status: {0}. Response Description: {1}", // response == null ? "-- null response --" : response.StatusCode.ToString(), // response == null ? string.Empty : response.StatusDescription)); //} //return response.Data; return null; }