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); }
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); }
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)); }