I have been stuck for couple of hours debugging some strange behaviour with the Graph API of Microsoft. I have made a onedrive importer/exporter a few years back and I am trying to get it to work again.
I get an error calling the following URL:
https://graph.microsoft.com/v1.0/me/drive/items/652C6732B5C9F652!s44efd855700c4a5da4bdfde318b6096b/content
The error is:
Status Code: 401 Unauthorized Response: {"error":{"code":"unauthenticated","message":"Unauthenticated"}}
If I retrieve the bearer token manually, I see the following files permissions:
https://graph.microsoft.com/Files.Read https://graph.microsoft.com/Files.Read.All https://graph.microsoft.com/Files.ReadWrite https://graph.microsoft.com/Files.ReadWrite.All
Now the strange part:
All the other requests are working fine. So I can retrieve a file list and even see the thumbnails with the call:
https://graph.microsoft.com/v1.0/me/drive/items/652C6732B5C9F652!s44efd855700c4a5da4bdfde318b6096b/thumbnails
That call should have the same permissions as the “content” call. So how is it possible I get a 401 on “content” and 200 on “thumbnails”?
It’s using the same bearer token, I checked the request params etc. Only changing the word “content” to another call makes it work. Is there some permissions I am missing?
I use the following simple example code to test it:
<cfhttp url="https://graph.microsoft.com/v1.0/me/drive/items/652C6732B5C9F652!s44efd855700c4a5da4bdfde318b6096b/content" method="get"> <cfhttpparam type="header" name="Authorization" value="Bearer [token]"> </cfhttp>