1
0
mirror of synced 2026-05-22 21:53:18 +00:00

👌 修改获取accessToken时的返回值为实体类,方便扩展

This commit is contained in:
yadong.zhang
2019-05-17 18:37:57 +08:00
parent 2e0262ed7e
commit 188c52ca6b
15 changed files with 102 additions and 48 deletions
@@ -6,8 +6,8 @@ import cn.hutool.json.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthDingTalkErrorCode;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.utils.GlobalAuthUtil;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -28,12 +28,15 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
}
@Override
protected String getAccessToken(String code) {
throw new AuthException(ResponseStatus.NOT_IMPLEMENTED);
protected AuthToken getAccessToken(String code) {
return AuthToken.builder()
.accessCode(code)
.build();
}
@Override
protected AuthUser getUserInfo(String code) {
protected AuthUser getUserInfo(AuthToken authToken) {
String code = authToken.getAccessCode();
// 根据timestamp, appSecret计算签名值
String stringToSign = System.currentTimeMillis() + "";
String urlEncodeSignature = GlobalAuthUtil.generateDingTalkSignature(config.getClientSecret(), stringToSign);
@@ -52,11 +55,4 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
.source(AuthSource.DINGTALK)
.build();
}
@Override
public AuthResponse login(String code) {
return AuthResponse.builder()
.data(this.getUserInfo(code))
.build();
}
}