Forum Discussion

jblum2000's avatar
jblum2000
Copper Contributor
Oct 29, 2026

API requests failing except for /me; permissions seem OK

Having trouble refitting my app from working with Dropbox to working with OneDrive.  My OAUTH login is working fine; inspecting the access token shows that I have an appropriate set of permissions ("scp": "Files.ReadWrite Files.ReadWrite.All FileStorageContainer.Selected User.Read profile openid email").  I make a GET request to "/me", and get a valid response.  I make the same request to "/me/drives", or "/me/drive", or "/me/drives/root", or a search URL under it -- and I get a 400 Bad Request error.

In all cases I'm using cpprestsdk, with the same client and a different request:

m_client = client::http_client(_T("https://graph.microsoft.com/v1.0/"), config);

(...)

pplx::task<json::value> myTask = m_client.request(http::methods::GET, endpointName)

...where "endpointName" is any of the above URL fragments in quotes.  If it's not a permissions issue, what could it be?

In addition -- I've tried checking my calls in the Graph Explorer while logged in as the same user (or so I thought), and they work there...  but inspecting the results of /me shows that they're not the same.  For example, the app shows 

"userPrincipalName":"my.name_mycompany.com#EXT#@MyCompany.onmicrosoft.com"

while the Explorer is logged in as

"userPrincipalName": "email address removed for privacy reasons"

.  Is there any way to make sure that the app actually does have the correct access to the OneDrive API?

2 Replies

  • The different results from /me are the strongest clue: the #EXT# username points to a guest representation, so your application and Graph Explorer are not necessarily testing the same tenant identity. Compare the tenant ID and user object ID in both contexts, rather than just the email address. Acquire the application token for the tenant containing the intended OneDrive and sign in as its licensed owner. Then test GET /me/drive followed by GET /me/drive/root. The singular drive relationship is important; /me/drives/root is not the documented root-folder request. Also log the actual request URI to confirm it retains the v1.0 segment, and capture the complete error code, message and request ID from the 400 response. Your listed file scopes already include access suitable for ordinary OneDrive calls; adding more permissions will not correct a different signed-in identity or malformed request.

  • jblum2000's avatar
    jblum2000
    Copper Contributor

    Update:  my code was eating the JSON response for the 400 error, which had an innerError message of "Tenant does not have a SPO license."  This seems odd, because while it's true that the tenant doesn't have a license (our company is actually using an Office365 Family plan and hasn't upgraded yet!), I thought the individual users were under the same plan as the tenant.  So it seems that when the individual user goes through the Graph Explorer, they have the necessary rights, but when they authenticate through our app the app's more restrictive license overrides theirs -- is that correct?  Could someone point me to the appropriate documentation?