QQ第三方登录流程

QQ第三方登录流程

qq的OAuth2流程比普通的OAuth2多了一步:用access_token获取openid,再使用openid和access_token获取用户信息

step 1:获取Authorization Code

请求url基本格式
https://graph.qq.com/oauth2.0/authorize&response_type=code&client_id=[your_app_id]&redirect_uri=[your_redirect_uri]&state=[csrf_token]
回调 :在请求成功后,qq会回调下面的url,你就可以获取到code
http://graph.qq.com/cb?code=[your_code]&state=[csrf_token]

Step2:通过Authorization Code获取Access Token

请求url基本格式
https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=[]&client_secret=[]&code=[上一步获得的code]&redirect_uri=[]
回调:
http://graph.qq.com/cb?access_token=[]&expires_in=7776000(秒)&refresh_token=[]

Step3:获取用户OpenID_OAuth2.0

请求url基本格式
https://graph.qq.com/oauth2.0/me?access_token=[上一步获得的token]
返回值:html格式
callback( {"client_id":"YOUR_APPID","openid":"YOUR_OPENID"} );

Step4:获取用户详细信息

请求url基本格式
https://graph.qq.com/user/get_user_info?access_token=YOUR_ACCESS_TOKEN&oauth_consumer_key=YOUR_APP_ID&openid=YOUR_OPENID
返回值:
{
"ret":0,
"msg":"",
"nickname":"YOUR_NICK_NAME",
...
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值