InvalidAuthenticationToken and CompactToken issues - Microsoft Graph using PHP Curl

半世苍凉 提交于 2019-12-20 05:40:43

问题


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"
}
}
}

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

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


回答1:


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

This triggered the above error:

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

This yielded the successful response:

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


来源:https://stackoverflow.com/questions/35665769/invalidauthenticationtoken-and-compacttoken-issues-microsoft-graph-using-php-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!