diff --git a/src/main/java/me/zhyd/oauth/model/AuthToken.java b/src/main/java/me/zhyd/oauth/model/AuthToken.java index e729b1dce3f19efb06477745e1a0be293748f87c..eb4c42b54ad3aa2ed8e8b1a9401a7c5efbd0abb1 100644 --- a/src/main/java/me/zhyd/oauth/model/AuthToken.java +++ b/src/main/java/me/zhyd/oauth/model/AuthToken.java @@ -44,6 +44,12 @@ public class AuthToken implements Serializable { * @since 1.10.0 */ private String code; + /** + * 微信公众号 - 网页授权的登录时可用 + * + * 微信针对网页授权登录,增加了一个快照页的逻辑,快照页获取到的微信用户的 uid oid 和头像昵称都是虚拟的信息 + */ + private boolean snapshotUser; /** * Twitter附带属性 diff --git a/src/main/java/me/zhyd/oauth/model/AuthUser.java b/src/main/java/me/zhyd/oauth/model/AuthUser.java index 530e73aabcba815038ebb640fc39662f420dbeef..ab88b522f5248bf7b473e58c42e370bfe3680b59 100644 --- a/src/main/java/me/zhyd/oauth/model/AuthUser.java +++ b/src/main/java/me/zhyd/oauth/model/AuthUser.java @@ -72,4 +72,11 @@ public class AuthUser implements Serializable { */ private JSONObject rawUserInfo; + /** + * 微信公众号 - 网页授权的登录时可用 + * + * 微信针对网页授权登录,增加了一个快照页的逻辑,快照页获取到的微信用户的 uid oid 和头像昵称都是虚拟的信息 + */ + private boolean snapshotUser; + } diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java index 94fcba8bc4dcfa43d3277593d24d39d12bb28da7..5ee1374bab8a4cd457feb5136838bcf544d5c717 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java @@ -65,6 +65,7 @@ public class AuthWeChatMpRequest extends AuthDefaultRequest { .avatar(object.getString("headimgurl")) .location(location) .uuid(openId) + .snapshotUser(authToken.isSnapshotUser()) .gender(AuthUserGender.getWechatRealGender(object.getString("sex"))) .token(authToken) .source(source.toString()) @@ -108,6 +109,7 @@ public class AuthWeChatMpRequest extends AuthDefaultRequest { .expireIn(accessTokenObject.getIntValue("expires_in")) .openId(accessTokenObject.getString("openid")) .scope(accessTokenObject.getString("scope")) + .snapshotUser(accessTokenObject.getIntValue("is_snapshotuser") == 1) .build(); }