提交 9e6a4c61 编写于 作者: qq_25784145's avatar qq_25784145

修复人人网返回token中有竖线(|)没有进行URL Encode操作导致的url解析失败的bug

上级 28466f8a
...@@ -13,6 +13,8 @@ import me.zhyd.oauth.model.AuthToken; ...@@ -13,6 +13,8 @@ import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser; import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.utils.UrlBuilder; import me.zhyd.oauth.utils.UrlBuilder;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Objects; import java.util.Objects;
import static me.zhyd.oauth.config.AuthDefaultSource.RENREN; import static me.zhyd.oauth.config.AuthDefaultSource.RENREN;
...@@ -70,13 +72,17 @@ public class AuthRenrenRequest extends AuthDefaultRequest { ...@@ -70,13 +72,17 @@ public class AuthRenrenRequest extends AuthDefaultRequest {
throw new AuthException("Failed to get token from Renren: " + jsonObject); throw new AuthException("Failed to get token from Renren: " + jsonObject);
} }
try {
return AuthToken.builder() return AuthToken.builder()
.tokenType(jsonObject.getString("token_type")) .tokenType(jsonObject.getString("token_type"))
.expireIn(jsonObject.getIntValue("expires_in")) .expireIn(jsonObject.getIntValue("expires_in"))
.accessToken(jsonObject.getString("access_token")) .accessToken(URLEncoder.encode(jsonObject.getString("access_token"), "UTF-8"))
.refreshToken(jsonObject.getString("refresh_token")) .refreshToken(URLEncoder.encode(jsonObject.getString("refresh_token"), "UTF-8"))
.openId(jsonObject.getJSONObject("user").getString("id")) .openId(jsonObject.getJSONObject("user").getString("id"))
.build(); .build();
} catch (UnsupportedEncodingException e) {
throw new AuthException("Failed to encode token" + e.getMessage());
}
} }
private String getAvatarUrl(JSONObject userObj) { private String getAvatarUrl(JSONObject userObj) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册