InvalidAuthenticationToken和CompactToken问题-使用PHP Curl的Microsoft Graph [英] InvalidAuthenticationToken and CompactToken issues - Microsoft Graph using PHP Curl

查看:167
本文介绍了InvalidAuthenticationToken和CompactToken问题-使用PHP Curl的Microsoft Graph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够通过使用户通过oauth(参数:代码)等登录成功获取access_token.但是,每次我尝试将授权标头(通过php)发布到图形端点(例如/me)时, ),最后出现此错误:

I'm able to successfully fetch an access_token from having the user login via oauth (parameter: code) etc. However, each time I attempt to post the authorization header (via php) to a graph endpoint (such as /me), I end up getting this error:


{
error: {
code: "InvalidAuthenticationToken",
message: "CompactToken parsing failed with error code: -2147184105",
innerError: {
request-id: "59cc0e42-90b7-445a-8bf7-009ff476bcbe",
date: "2016-02-27T04:39:09"
}
}
}

什么是CompactToken解析?有没有办法找出解决此问题的方法?

What's CompactToken parsing? Is there a way to find out what's going on to fix this?

注意:在撰写本文时,还没有适用于Microsoft Graph的PHP SDK,因此我只是使用php进行curl调用

Note: at the time of this writing, there is no PHP SDK for Microsoft Graph, so I'm just making curl calls using php

推荐答案

此错误显然是由于在curl请求中将OAuth令牌作为OAuth而不是Bearer发送的.

This error is apparently due to sending the OAuth token as OAuth instead of Bearer in the curl request.

这触发了以上错误:


curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: 0',
    'Authorization: OAuth '.$token)                                                                       
);        

这产生了成功的响应:


curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: 0',
    'Authorization: Bearer '.$token)                                                                       
);        

这篇关于InvalidAuthenticationToken和CompactToken问题-使用PHP Curl的Microsoft Graph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆