Ejemplo n.º 1
0
        private static HttpWebRequest GetAccessTokenRequest(IAuthenticationContext authenticationContext, string oauthVerifier)
        {
            RequestParameters accessTokenRequestParameters =
                new AccessTokenRequestParameters(authenticationContext, oauthVerifier);

            return(GetWebRequest(authenticationContext, accessTokenRequestParameters));
        }
 protected override IAccessTokenRequest CreateAccessTokenRequest(AccessTokenRequestParameters parameters)
 {
     return new AccessTokenRequest(UrlUtil.Combine(ApiBasePath, "access_token"), HttpClient)
     {
         Method = HttpMethod.Post
     };
 }
        public override AccessTokenResult GetAccessToken(AccessTokenRequestParameters parameters)
        {
            // state must be null in google
            parameters.State = null;

            return base.GetAccessToken(parameters);
        }
        protected override AccessTokenResult ParseAccessTokenResponse(string responseText, AccessTokenRequestParameters request)
        {
            var result = (ApiResponse)JsonSerializer.Deserialize(responseText, typeof(ApiResponse));

            return new TaobaoAccessTokenResponse
            {
                AccessToken = result.access_token,
                AccessTokenExpireTime = DateTime.Now.AddSeconds(result.expires_in),
                RefreshToken = result.refresh_token,
                UserId = result.taobao_user_id,
                UserNick = result.taobao_user_nick
            };
        }
        protected override AccessTokenResult ParseAccessTokenResponse(string responseText, AccessTokenRequestParameters request)
        {
            var result = AccessTokenRequestResult.Parse(responseText);

            if (!result.IsValid)
                throw new ApiException("Invalid response when request access token: " + responseText + ".");

            return new TencentAccessTokenResponse
            {
                AccessToken = result.Token,
                AccessTokenExpireTime = DateTime.Now.AddSeconds(result.Expires),
                RefreshToken = result.RefreshToken,
                UserName = result.Name
            };
        }
 protected override IAccessTokenRequest CreateAccessTokenRequest(AccessTokenRequestParameters parameters)
 {
     return new GoogleAccessTokenRequest(HttpClient);
 }
Ejemplo n.º 7
0
 protected override IAccessTokenRequest CreateAccessTokenRequest(AccessTokenRequestParameters parameters)
 {
     return new TencentAccessTokenRequest(UrlUtil.Combine(ApiBasePath, "token"), HttpClient);
 }
 protected override IAccessTokenRequest CreateAccessTokenRequest(AccessTokenRequestParameters parameters)
 {
     return new TaobaoAccessTokenRequest(ApiBasePath, HttpClient);
 }