Ejemplo n.º 1
0
        public async Task <TwitterAccessTokenResponse> GetAccessTokenAsync(string loginToken, string oauthToken, string oauthVerifier)
        {
            var oauth = new Oauth(_configuration.AppId, _configuration.AppSecret, AccessTokenUri)
            {
                AccessSecret = loginToken
            };

            oauth.AddOauthParameter("token", oauthToken);
            oauth.AddParameter("oauth_verifier", oauthVerifier);

            try
            {
                var oauthResult = await oauth.DoRequest();

                return(new TwitterAccessTokenResponse
                {
                    ScreenName = oauthResult["screen_name"],
                    UserId = oauthResult["user_id"]
                });
            }
            catch (Exception ex)
            {
                throw new TwitterClientException(ex);
            }
        }
Ejemplo n.º 2
0
        public async Task <TwitterRequestTokenResponse> GetRequestTokenAsync()
        {
            var oauth = new Oauth(_configuration.AppId, _configuration.AppSecret, RequestTokenUri);

            oauth.AddOauthParameter("callback", _configuration.Callback);

            try
            {
                var oauthResult = await oauth.DoRequest();

                return(new TwitterRequestTokenResponse
                {
                    OAuthToken = oauthResult["oauth_token"]
                });
            }
            catch (Exception ex)
            {
                throw new TwitterClientException(ex);
            }
        }