微信与QQ授权登录

原文地址为: 微信与QQ授权登录

一、微信授权
1.授权页面跳转至微信授权地址
https://open.weixin.qq.com/connect/oauth2/authorize?appid=WX_APP_ID&redirect_uri=$callback&response_type=code&scope=snsapi_base&state=state&#wechat_redirect
2.静默授权成功后,自动跳转至回调页面,并携带code
3.使用code获取unionid
https://api.weixin.qq.com/sns/oauth2/access_token?appid=WX_APP_ID&secret=WX_APP_SECRET&code=code&grant_type=authorization_code

备注 snsapi_base与snsapi_userinfo区别

二、QQ授权
1.授权页面跳转至QQ授权地址
https://graph.qq.com/oauth2.0/authorize?response_type=code&state=test&client_id=QQ_APP_ID&redirect_uri=callback&scope=get_user_info,get_simple_userinfo
2、授权成功后,自动跳转至回调页面,并携带code,使用code换取access_token
https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=QQ_APP_ID&client_secret=QQ_APP_KEY&code=$code&redirect_uri=callback
3、使用access_token获取openid
https://graph.qq.com/oauth2.0/me?access_token=access_token


转载请注明本文地址: 微信与QQ授权登录

猜你喜欢

转载自blog.csdn.net/chch998/article/details/80888788