提交 525c406c 编写于 作者: 智布道's avatar 智布道 👁

🐛 修复抖音登录取值取错层级的问题(issue#I15SIG@Gitee)

上级 e65d87da
......@@ -67,7 +67,7 @@
- 网站B:可以理解成 Oschina
- 第三方C:可以理解成 Github
需求:你想通过Github第三方登录Oschina
需求:你想通过Github第三方登录Oschina。(_注:下面的内容为流程图,如果您在阅读的时候显示为纯文字,请刷新页面_)
<div class="mermaid">
sequenceDiagram
......
......@@ -94,10 +94,15 @@ public abstract class AuthDefaultRequest implements AuthRequest {
*/
private AuthResponse responseError(Exception e) {
int errorCode = AuthResponseStatus.FAILURE.getCode();
String errorMsg = e.getMessage();
if (e instanceof AuthException) {
errorCode = ((AuthException) e).getErrorCode();
AuthException authException = ((AuthException) e);
errorCode = authException.getErrorCode();
if (StringUtils.isNotEmpty(authException.getErrorMsg())) {
errorMsg = authException.getErrorMsg();
}
return AuthResponse.builder().code(errorCode).msg(e.getMessage()).build();
}
return AuthResponse.builder().code(errorCode).msg(errorMsg).build();
}
/**
......
......@@ -42,13 +42,15 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
HttpResponse response = doGetUserInfo(authToken);
JSONObject userInfoObject = JSONObject.parseObject(response.body());
this.checkResponse(userInfoObject);
JSONObject dataObj = userInfoObject.getJSONObject("data");
return AuthUser.builder()
.uuid(userInfoObject.getString("union_id"))
.username(userInfoObject.getString("nickname"))
.nickname(userInfoObject.getString("nickname"))
.avatar(userInfoObject.getString("avatar"))
.remark(userInfoObject.getString("description"))
.gender(AuthUserGender.UNKNOWN)
.uuid(dataObj.getString("union_id"))
.username(dataObj.getString("nickname"))
.nickname(dataObj.getString("nickname"))
.avatar(dataObj.getString("avatar"))
.remark(dataObj.getString("description"))
.gender(AuthUserGender.getRealGender(dataObj.getString("gender")))
.location(String.format("%s %s %s", dataObj.getString("country"), dataObj.getString("province"), dataObj.getString("city")))
.token(authToken)
.source(source.toString())
.build();
......@@ -87,12 +89,13 @@ public class AuthDouyinRequest extends AuthDefaultRequest {
String accessTokenStr = response.body();
JSONObject object = JSONObject.parseObject(accessTokenStr);
this.checkResponse(object);
JSONObject dataObj = object.getJSONObject("data");
return AuthToken.builder()
.accessToken(object.getString("access_token"))
.openId(object.getString("open_id"))
.expireIn(object.getIntValue("expires_in"))
.refreshToken(object.getString("refresh_token"))
.scope(object.getString("scope"))
.accessToken(dataObj.getString("access_token"))
.openId(dataObj.getString("open_id"))
.expireIn(dataObj.getIntValue("expires_in"))
.refreshToken(dataObj.getString("refresh_token"))
.scope(dataObj.getString("scope"))
.build();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册