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

👽 修改login方法的参数为AuthCallback,封装回调返回的参数、支持state参数、增加code和state参数校验

This commit is contained in:
yadong.zhang
2019-06-27 19:39:21 +08:00
parent 9941ce7e2a
commit ac4ede74bf
31 changed files with 187 additions and 107 deletions
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -25,9 +26,9 @@ public class AuthFacebookRequest extends BaseAuthRequest {
}
@Override
protected AuthToken getAccessToken(String code) {
String accessTokenUrl = UrlBuilder.getFacebookAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
.getRedirectUri());
protected AuthToken getAccessToken(AuthCallback authCallback) {
String accessTokenUrl = UrlBuilder.getFacebookAccessTokenUrl(config.getClientId(), config.getClientSecret(),
authCallback.getCode(), config.getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
JSONObject object = JSONObject.parseObject(response.body());