问题
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