1
votes

I am building an app (HTTPS calls from LabVIEW) that will update my enterprise OneNote notebooks on Office 365 without the need for any user interaction. Hence I have opted for using the Client Credentials flow and granting Application permissions in Azure AD to my app (Read and write all OneNote notebooks) through Microsoft Graph. I have referred to the instructions mentioned in the following pages:

https://msdn.microsoft.com/en-us/office/office365/howto/onenote-auth-appperms

https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference

https://docs.microsoft.com/en-gb/azure/active-directory/develop/active-directory-v2-protocols-oauth-client-creds

https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service

https://developer.microsoft.com/en-us/graph/docs/concepts/onenote-create-page

I am able to get an access token from Microsoft Graph but once I try to use it to update my notebooks by making a POST call to the URL https://graph.microsoft.com/v1.0/me/onenote/pages I get the error: "The OneDriveForBusiness for this user account cannot be retrieved." Code - 30108

However, I am fully able to access OneDriveForBusiness online using the same account which created the app and the tenant ID of which I used to grant permissions. Can someone please clarify if there are certain restrictions regarding the type of O365 and OneDriveForBusiness subscriptions that are necessary for my requirements? Which particular subscription or their combinations thereof should allow me to achieve the flow I need?

1

1 Answers

1
votes

You cannot use /me with Client Credentials. /me is an alias for /users/{currentUserId but since you're using Client Credentials, there is a User in context for the API to map that alias to. You are effectively calling /v1.0/users/NULL/onenote/pages in this case.

You need to explicitly specify the User you want to access:

/v1.0/users/{userId or userPrincipalName}/onenote/pages