public virtual OAuthAccessToken GetAccessToken(OAuthRequestToken requestToken, string?verifier) { if (_consumerKey == null || _consumerSecret == null) { throw new InvalidOperationException("_consumerKey == null || _consumerSecret == null"); } var args = new FunctionArguments ( _consumerKey, _consumerSecret, requestToken.Token, requestToken.TokenSecret, verifier ); var request = _accessTokenQuery.Invoke(args); var response = _oauth.Request(request); SetResponse(response); var query = OAuthWorkflow.ParseQuery(response.Content); var accessToken = new OAuthAccessToken ( query["oauth_token"] ?? "?", query["oauth_token_secret"] ?? "?", Convert.ToInt64(query["user_id"] ?? "0"), query["screen_name"] ?? "?" ); return(accessToken); }
public virtual OAuthRequestToken GetRequestToken(string?callback) { if (_consumerKey == null || _consumerSecret == null) { throw new InvalidOperationException("_consumerKey == null || _consumerSecret == null"); } var args = new FunctionArguments ( _consumerKey, _consumerSecret ); var request = _requestTokenQuery.Invoke(args); if (!callback.IsNullOrBlank()) { request.AddParameter("oauth_callback", callback !); } var response = _oauth.Request(request); SetResponse(response); var query = OAuthWorkflow.ParseQuery(response.Content); var oauth = new OAuthRequestToken ( query["oauth_token"] ?? "?", query["oauth_token_secret"] ?? "?", Convert.ToBoolean(query["oauth_callback_confirmed"] ?? "false") ); return(oauth); }
public virtual void GetAccessToken(OAuthRequestToken requestToken, string?verifier, Action <OAuthAccessToken?, TwitterResponse> action) { if (_consumerKey == null || _consumerSecret == null || requestToken.TokenSecret == null) { throw new InvalidOperationException("_consumerKey == null || _consumerSecret == null || requestToken.TokenSecret == null"); } var args = new FunctionArguments ( _consumerKey, _consumerSecret, requestToken.Token, requestToken.TokenSecret, verifier ); var request = _accessTokenQuery.Invoke(args); _oauth.BeginRequest(request, (req, resp, state) => { Exception?exception; var entity = TryAsyncResponse(() => { if (resp == null || resp.StatusCode != HttpStatusCode.OK) { return(null); } var query = OAuthWorkflow.ParseQuery(resp.Content); var accessToken = new OAuthAccessToken ( query["oauth_token"] ?? "?", query["oauth_token_secret"] ?? "?", Convert.ToInt64(query["user_id"] ?? "0"), query["screen_name"] ?? "?" ); return(accessToken); }, out exception); action(entity, new TwitterResponse(resp, exception)); } ); }
public virtual void GetRequestToken(string callback, Action <OAuthRequestToken?, TwitterResponse> action) { if (_consumerKey == null || _consumerSecret == null) { throw new InvalidOperationException("_consumerKey == null || _consumerSecret == null"); } var args = new FunctionArguments ( _consumerKey, _consumerSecret ); var request = _requestTokenQuery.Invoke(args); if (!callback.IsNullOrBlank()) { request.AddParameter("oauth_callback", callback); } _oauth.BeginRequest(request, (req, resp, state) => { Exception?exception; var entity = TryAsyncResponse(() => { if (resp == null || resp.StatusCode != HttpStatusCode.OK) { return(null); } var query = OAuthWorkflow.ParseQuery(resp.Content); var requestToken = new OAuthRequestToken ( query["oauth_token"] ?? "?", query["oauth_token_secret"] ?? "?", Convert.ToBoolean(query["oauth_callback_confirmed"] ?? "false") ); return(requestToken); }, out exception); action(entity, new TwitterResponse(resp, exception)); }); }