微信 oauth授权2

2.前面请求成功后 会在跳转url后得到

?code=00b788e3b42043c8459a57a8d8ab5d9f&state=1


3.之后

使用code换取access_token

换取网页授权access_token页面的构造方式:

https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code

参数说明

参数是否必须说明
appid 公众号的唯一标识
secret 公众号的appsecret
code 填写第一步获取的code参数
grant_type 填写为authorization_code

code:在这里填写为上一步获得的值

构造请求url如下:

https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx8888888888888888&secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&code=00b788e3b42043c8459a57a8d8ab5d9f&grant_type=authorization_code
原文地址:https://www.cnblogs.com/yelongsan/p/6408312.html