Search code examples
azuremicrosoft-graph-apionedrive

Access Personal OneDrive API with client_credentials


For a project, I need to display some files stored on a Personal OneDrive.

I can't use a classic OAuth2 authentication, I need to be authenticate as an application and not as an user, like explained on this page : https://learn.microsoft.com/en-us/graph/auth-v2-service

But adminConsent seems to be only for entreprise subscriptions. Is there any way to do that with a Personal OneDrive ?


Solution

  • I finally find a solution with Code Flow authentication and offline_access scope. With that method, an admin have to connect one time to get a refresh token which can be uses after to get an access_token at any time.

    https://learn.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/msa-oauth?view=odsp-graph-online#code-flow