今天发现一个现象,按照微信官方文档: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842
#第一步:用户同意授权,获取 code
假设我有 https://example.com/getUser.html 的页面跳转获取用户授权的 code: https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
那么,相应 scope 为 snsapi_base 的模式下就是: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx520c15f417810387&redirect_uri=https%3A%2F%2Fexample.com%2FgetUser.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect
scope 为 snsapi_userinfo 模式下就是: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=https%3A%2F%2Fexample.com%2FgetUser.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
实测我在 Play 版本的微信(6.6.1)上扫码进入,通过 Fiddler 观察,微信打开了 https://example.com/getUser.html
scope 为 snsapi_userinfo 模式的时候并不是进入到微信官方文档的那个用户授权页面 https://i.loli.net/2018/01/26/5a6af53c4d6b5.jpg
而是一个弹层,选择授权或拒绝。Fiddler 已经开启 https 远程捕获并在手机上安装了 Root 证书。
选择授权时,成功通过 code 换取到 access_token,并利用 access_token 和 openid 取到用户信息;选择拒绝时,页面未作跳转,依旧停留在 https://example.com/getUser.html
所以,现在公众号网页授权的跳转是怎样的了?
#第一步:用户同意授权,获取 code
假设我有 https://example.com/getUser.html 的页面跳转获取用户授权的 code: https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
那么,相应 scope 为 snsapi_base 的模式下就是: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx520c15f417810387&redirect_uri=https%3A%2F%2Fexample.com%2FgetUser.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect
scope 为 snsapi_userinfo 模式下就是: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=https%3A%2F%2Fexample.com%2FgetUser.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
实测我在 Play 版本的微信(6.6.1)上扫码进入,通过 Fiddler 观察,微信打开了 https://example.com/getUser.html
scope 为 snsapi_userinfo 模式的时候并不是进入到微信官方文档的那个用户授权页面 https://i.loli.net/2018/01/26/5a6af53c4d6b5.jpg
而是一个弹层,选择授权或拒绝。Fiddler 已经开启 https 远程捕获并在手机上安装了 Root 证书。
选择授权时,成功通过 code 换取到 access_token,并利用 access_token 和 openid 取到用户信息;选择拒绝时,页面未作跳转,依旧停留在 https://example.com/getUser.html
所以,现在公众号网页授权的跳转是怎样的了?