Search in sources :

Example 1 with AlipaySystemOauthTokenResponse

use of com.alipay.api.response.AlipaySystemOauthTokenResponse in project dq-easy-cloud by dq-open-cloud.

the class EcZfbOauthToken method doGetOauthAccessToken.

@Override
public Map<String, Object> doGetOauthAccessToken() throws Exception {
    AlipaySystemOauthTokenRequest oauthTokenRequest = new AlipaySystemOauthTokenRequest();
    oauthTokenRequest.setCode(super.authCode);
    oauthTokenRequest.setGrantType(grantType);
    AlipaySystemOauthTokenResponse oauthTokenResponse = alipayClient.execute(oauthTokenRequest);
    EcAssert.verifyObjNull(oauthTokenResponse, "oauthTokenResponse");
    if (oauthTokenResponse != null && oauthTokenResponse.isSuccess()) {
        Map<String, Object> tokenRepParam = EcMapUtils.newHashMap();
        tokenRepParam.put(EcOauthAccessToken.ACCESS_TOKEN, oauthTokenResponse.getAccessToken());
        tokenRepParam.put(EcOauthAccessToken.EXPIRES_IN, oauthTokenResponse.getExpiresIn());
        tokenRepParam.put(EcOauthAccessToken.REFRESH_TOKEN, oauthTokenResponse.getRefreshToken());
        tokenRepParam.put(EcOauthAccessToken.AUTH_TOKEN_TYPE, oauthTokenResponse.getAuthTokenType());
        tokenRepParam.put(EcOauthAccessToken.OPENID, oauthTokenResponse.getUserId());
        tokenRepParam.put(EcOauthAccessToken.RE_EXPIRES_IN, oauthTokenResponse.getReExpiresIn());
        return tokenRepParam;
    } else {
        throw new EcBaseBusinessException(oauthTokenResponse.getCode(), oauthTokenResponse.getMsg()).buildExceptionDetail(oauthTokenResponse);
    }
}
Also used : AlipaySystemOauthTokenRequest(com.alipay.api.request.AlipaySystemOauthTokenRequest) AlipaySystemOauthTokenResponse(com.alipay.api.response.AlipaySystemOauthTokenResponse) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException)

Aggregations

AlipaySystemOauthTokenRequest (com.alipay.api.request.AlipaySystemOauthTokenRequest)1 AlipaySystemOauthTokenResponse (com.alipay.api.response.AlipaySystemOauthTokenResponse)1 EcBaseBusinessException (com.easy.cloud.core.exception.bo.EcBaseBusinessException)1