H5微信授權登錄流程


1.獲取code

var jumpUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?'
  var params = {
    appid: '', // 公眾號appid
    redirect_uri: 'http://woejfoa.com/a/s.html', //回調地址,域名配置同一地址 定位到目錄
    response_type: 'code',
    scope: 'snsapi_userinfo',// 需要用戶確認登錄
    state: 'STATE'
  }
  jumpUrl += $.param(params) + '#wechat_redirect'
  location.href = jumpUrl // 獲取code跳轉到回調地址

在回調地址頁面截取url獲得code

2.通過接口把code傳給后台服務器,后台通過code獲得access_token openid 等用戶信息返回給前端就可以了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM