加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 缺少必需参数:在ionic2中访问google令牌时的grant_t

发布时间:2020-12-17 17:17:18 所属栏目:安全 来源:网络整理
导读:缺少必需参数:在ionic2中访问google令牌时的grant_type 错误:- { "error" : "invalid_request","error_description" : "Required parameter is missing: grant_type"} 码 let creds=JSON.stringify({ 'client_id':'251059024984-8113pdtb11gm8m4evdq59stlp
缺少必需参数:在ionic2中访问google令牌时的grant_type

错误:-

{
  "error" : "invalid_request","error_description" : "Required parameter is missing: grant_type"
}

let creds=JSON.stringify({
        'client_id':'251059024984-8113pdtb11gm8m4evdq59stlpvcab8cn.apps.googleusercontent.com','client_secret':'uVWZt_Vd5mMLXGQDo7lmAIUe','redirect_uri':'http://localhost/callback','grant_type':'authorization_code','code':data
    });
    var headers = new Headers();
    headers.append('Content-Type','application/x-www-form-urlencoded');
    console.log(data)


    this.http.post('https://accounts.google.com/o/oauth2/token',creds,{headers: headers}).map(res => res.json()).subscribe(data => {
        console.log(data)
    },(error)=>{
        console.log('error in',error);
    })

当我检查邮递员的api工作完美

enter image description here

解决方法

let creds = 'client_id=251059024984-8113pdtb11gm8m4evdq59stlpvcab8cn.apps.googleusercontent.com'
    +'&client_secret=uVWZt_Vd5mMLXGQDo7lmAIUe'
    +'&redirect_uri=http://localhost/callback'
    +'&grant_type=authorization_code'
    +'&code=' + data

JSON.stringify()不是正确的格式

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读