2
votes

I'm trying to access my OneDrive (personal account) files using the Microsoft Graph API but I can't get it to work. I have read for days now whithout luck. I'm using the "Client Credentials Flow". I have created an application in the Application Registration Portal and I have set application permissions. It works fine to get a token but when I try to read the root of OneDrive using this token it says "Access Denied", "Either scp or roles claim need to be present in the token.". This happens when I use the v2.0 version to get the token and then the v1.0 version to access OneDrive. I.e. I use this URL to get the token: https://login.microsoftonline.com/common/oauth2/v2.0/token and this URL to get the OneDrive root: https://graph.microsoft.com/v1.0/drive/root?$expand=thumbnails,children($expand=thumbnails)

It works fine when I do the "Authorization Code Flow".

What can be the problem?

1

1 Answers

1
votes

For personal accounts and data associated to personal accounts (like a personal OneDrive), only delegated (authorization code flow) is supported. Client credential flow is not supported here. Client credential flow is only supported for commercial (Azure AD) scenarios.

Do you have a particular scenario in mind as to why you need to use client credentials flow (versus authorization code flow) against personal OneDrive?

Hope this helps,