/// <summary> /// 获取授权 /// </summary> public virtual OpenApiResult <AccessGrant> UserAuthorize(SimpleTokenData tokenData) { var result = OAuthOperator.GetToken(tokenData); if (result.Code == 0) { OnUserAuthorizeSuccess(result.Data); } return(result); }
public virtual AccessGrant AppAuthorize() { var tokenData = new ClientCredentialsTokenData(OAuthContext.ClientId, OAuthContext.ClientSecret); var result = OAuthOperator.GetToken(tokenData); if (result.Code != 0) { throw new OAuthException("应用授权失败。" + result.Message); } OnAppAuthorizeSuccess(result.Data); return(result.Data); }
/// <summary> /// 刷新 AccessToken /// </summary> public virtual AccessGrant RefreshToken(AccessGrant accessGrant) { RefreshTokenData tokenData = CreateRefreshTokenTokenData(accessGrant); var result = OAuthOperator.GetToken(tokenData); if (result.Code == 0) { var ag = result.Data; if (ag.UserId == 0) { OnAppAuthorizeSuccess(ag); } else { OnUserAuthorizeSuccess(ag); } return(ag); } throw new OAuthException(result.Code + ":" + result.Message); }