- 第一步:用户同意授权,获取code
- 第二步:通过code换取网页授权access_token
- 第三步:刷新access_token(如果需要)
- 第四步:拉取用户信息(需scope为 snsapi_userinfo)
- 检验授权凭证(access_token)是否有效
1.用户同意授权,获取code
接口路径:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
参数说明:
参数 | 说明 |
---|---|
appid | 公众号的唯一标识 , 后台获取 |
redirect_uri | 授权后重定向的回调链接地址 ,可带参,但太多会被截掉 |
response_type | 填code |
scope | 授权作用域,snsapi_base (不弹出授权页面,直接跳 |