Search code examples
c#ms-officeonenoteonenote-api

Issue with OneNote permissions


I'm trying to create a sample app which can get and post new pages from my one note account.

I'm following this guide: https://msdn.microsoft.com/en-us/office/office365/howto/onenote-auth

I was correctly able to get the access token through the microsoft account, but every call to the OneNote apis fails with a 401 error.

I'm working in c# and using the HttpWebRequest to perform the calls.

My suspects are related to the permissions which I wasn't able to set: https://msdn.microsoft.com/en-us/office/office365/howto/onenote-auth#onenote-perms-msa

How can I set those permissions?

Thanks everybody for your help.


Solution

  • Which Scopes are you setting? Scopes (or permissions) are ser via a query parameter when redirecting the user to the sign in page. For creating a page you'll need at least office.onenote_create.

    https://msdn.microsoft.com/en-us/library/office/dn807159.aspx

    Depending on whether you're working on a webpage or a windows app, we have plenty of samples to look at.

    For client side (C#) https://github.com/OneNoteDev/OneNoteAPISampleWinUniversal https://github.com/OneNoteDev/OneNoteAPISampleWinStore

    For server side (we don't have. C# sample yet) https://github.com/OneNoteDev/OneNoteAPISampleNodejs