Esempio n. 1
0
 public async Task AuthorizeAccessAsync(CancellationToken cancelToken)
 {
     IAuthTokenFactory oAuthTokenFactory = new JDCBOAuth2TokenFactory   //<--this part could use ioc 
     {
         OAuthSettings = OAuthSettings,
         AuthorizationCode = AuthorizationCode,
         AccessToken = AccessToken,
         GrantType = OAuthLib.GrantType.AuthorizationCode
     };
     this.CurrentAuthToken = await oAuthTokenFactory.CreateTokenAsync(cancelToken);
 }
Esempio n. 2
0
        public static async Task<AuthToken> CreateOAuthTokenAsync(string appKey, string appSecret, string code, CancellationToken cancelToken)
        {
            var authorizeUrl = "https://api.weibo.com/oauth2/authorize"; //<--these should get from resource
            var accessTokenUrl = "https://api.weibo.com/oauth2/access_token"; //<--these should get from resource
            var callbackUrl = "https://api.weibo.com/oauth2/default.html";

            IAuthTokenFactory oAuthTokenFactory = new JDCBOAuth2TokenFactory   //<--this part could use ioc 
            {
                OAuthSettings = new OAuthSettings
                {
                    AuthorizeUrl = authorizeUrl,
                    AccessTokenUrl = accessTokenUrl,
                    CallbackUrl = callbackUrl,
                    AppKey = appKey,
                    AppSecret = appSecret
                },
                AuthorizationCode = code,
                GrantType = OAuthLib.GrantType.AuthorizationCode
            };
            return await oAuthTokenFactory.CreateTokenAsync(cancelToken);
        }
Esempio n. 3
0
        public static async Task <AuthToken> CreateOAuthTokenAsync(string appKey, string appSecret, string code, CancellationToken cancelToken)
        {
            var authorizeUrl   = "https://api.weibo.com/oauth2/authorize";    //<--these should get from resource
            var accessTokenUrl = "https://api.weibo.com/oauth2/access_token"; //<--these should get from resource
            var callbackUrl    = "https://api.weibo.com/oauth2/default.html";

            IAuthTokenFactory oAuthTokenFactory = new JDCBOAuth2TokenFactory   //<--this part could use ioc
            {
                OAuthSettings = new OAuthSettings
                {
                    AuthorizeUrl   = authorizeUrl,
                    AccessTokenUrl = accessTokenUrl,
                    CallbackUrl    = callbackUrl,
                    AppKey         = appKey,
                    AppSecret      = appSecret
                },
                AuthorizationCode = code,
                GrantType         = OAuthLib.GrantType.AuthorizationCode
            };

            return(await oAuthTokenFactory.CreateTokenAsync(cancelToken));
        }