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",
...
}