公众号登陆流程
2019-08-15 本文已影响0人
zhao_madman
![](https://img.haomeiwen.com/i5811737/e861af23e486d11e.png)
前端操作:前端获取code,然后调取后端接口后端去执行三四步,直接返回个人信息
第一步:用户同意授权,获取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参数对应的授权作用域权限。
![](https://img.haomeiwen.com/i5811737/86d61a01e966fa6d.png)
![](https://img.haomeiwen.com/i5811737/86fc80ff587ed9e0.png)
第二步:通过code换取网页授权access_token
https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
![](https://img.haomeiwen.com/i5811737/6978858bc2d90613.png)
![](https://img.haomeiwen.com/i5811737/7b6beffc1bf132ad.png)
第三步:拉取用户信息(需scope为 snsapi_userinfo)
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
![](https://img.haomeiwen.com/i5811737/98d160ab20f43274.png)
![](https://img.haomeiwen.com/i5811737/6a8359d0d739f419.png)