微信與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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章