zoukankan      html  css  js  c++  java
  • H5页面获取微信信息授权,微信授权,微信授权“redirect_uri 参数错误

     this.wxInfo.redirect_uri = encodeURIComponent(window.location.href);
            var h =
              "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
              this.wxInfo.appid +
              "&redirect_uri=" +
              this.wxInfo.redirect_uri +
              "&response_type=code&scope=" +
              this.wxInfo.scope +
              "&state=" +
              this.wxInfo.state +
              "#wechat_redirect";
    
            window.location.href = h;

    H5页面获取微信信息授权-主要参数说明:

    redirect_uri 是微信授权后回调的地址参数建议encodeURIComponent一下地址,避免出错(微信公众号授权登录,提示“redirect_uri 参数错误”
    appid 是微信公众号id
     scope  获取用户信息 "snsapi_userinfo"
     
    授权成功后会回调到redirect_uri 地址并在地址后面加上code=XX&state=XX
     
    如果取到了code=XX&state=XX,调用后端接口传这两个参数给后端去取openId并判断用户信息
     
     
    微信授权拒绝
    由于拒绝授权,微信将回调到redirect_uri,但并不在参数后面添加信息
     
     
     
     
  • 相关阅读:
    走线规范-标识
    python学习之网路操作
    python学习之函数
    RTT学习之软件包
    RT_THREAD之组件学习
    RT_THREAD之nano学习
    物联网相关的模块
    JavaScript学习笔记之二
    javascript完美实现图片拖动改变顺序
    响应式WEB设计的9项基本原则
  • 原文地址:https://www.cnblogs.com/FACESCORE/p/13214712.html
Copyright © 2011-2022 走看看