I'm trying to write an R package to let users access the files in their OneDrive folders from R. The API is Microsoft Graph.
Everything is working fine with OneDrive for Business (which is basically SharePoint under the hood, as I understand it). However, I can't get it to work with personal OneDrive.
Custom app registration, consumers
authorization endpoint
When I use an app registration under my own AAD tenant, I get the following error from the consumers
AAD authorization endpoint:
AADSTS50020: User account '[email protected]' from identity provider 'live.com' does not exist in tenant 'Consumers' and cannot access the application 'd44a05d5-c6a5-4bbb-82d2-443123722380'(AzureRtest_cli) in that tenant. The account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Azure Active Directory user account.
Custom app registration, 9188040d-6c67-4c5b-b112-36a304b66dad
endpoint
From this page it appears that the token should be for the tenant 9188040d-6c67-4c5b-b112-36a304b66dad
instead of the generic consumers
. When I tried that, I obtained a seemingly valid token. However, talking to the https://api.onedrive.com/v1.0/drive
endpoint results in a cryptic 401 error.
Azure CLI app registration, consumers
endpoint
As a hack, I tried piggybacking off the Azure CLI's app registration. This fails with
AADSTS65002: Consent between first party application '04b07795-8ddb-461a-bbee-02f9e1bf7b46' and first party resource '00000003-0000-0000-c000-000000000000' must be configured via preauthorization. Visit https://identitydocs.azurewebsites.net/static/aad/preauthorization.html for details
Azure CLI app registration, 9188040d-6c67-4c5b-b112-36a304b66dad
endpoint
Finally, I tried using the CLI app registration with this tenant, which also failed:
unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.
What are the exact steps I need to do to get to my personal OneDrive?
consumers
authorization endpoint. – Allen Wugraph.microsoft.com
to get to my personal Onedrive, notapi.onedrive.com
? – Hong Ooigraph.microsoft.com
because the access token is for Microsoft Graph rather thanapi.onedrive.com
. You have solved this issue right? Can you post an answer to help others? – Allen Wu