0
votes

I am building a single page app with JavaScript to access a users OneNote notebooks.

Using this git project as a starting point: https://github.com/OfficeDev/O365-Angular-Microsoft-Graph-Connect

I set up the app in Azure AD with full permissions to MS graph.

I can login and get a bearer token, however I can't pull any information from my OneNote notebooks using this endpoint: graph.microsoft.com/beta/me/notes/notebooks.

Here's my function:

function connectToOneNote(){
    var request = {
        method: 'GET',
        url: 'https://graph.microsoft.com/beta/me/notes/notebooks',
    };

  // Execute the HTTP request. 
  $http(request)
    .then(function (response) {
      $log.debug('HTTP request to Microsoft Graph API returned successfully.', response);     
      response.status === 202 ? vm.requestSuccess = true : vm.requestSuccess = false; 
      vm.requestFinished = true;
    }, function (error) {
      $log.error('HTTP request to Microsoft Graph API failed.');
      vm.requestSuccess= false;
      vm.requestFinished = true;
    });
};        

I get this error: "The OneDriveForBusiness for this user account cannot be retrieved."

However when using the endpoint in the graph explorer: https://graph.microsoft.io/en-us/graph-explorer, my notebooks are retrieved without issue.

Any ideas?

1
Are you sure, you have set the correct autorizations in your Azure manfist ?Sébastien Pertus
Thanks. Yes. I gave the app elevated permissions to ms graph and changed the oauth2AllowImplicitFlow value to 'true'. Do you think there is more?LSmee
Can you be a little more specific in defining "full permissions to MS graph". Did you check every single permission in the AAD portal (for user and app permissions, or just app permissions?) For your scenario this sounds like rather too many permissions, although the error you are getting doesn't sound like it corresponds to this problem, we might be able to make progress y dialing back to just the appropriate OneNote permissions and working from there.GarethJ

1 Answers

0
votes

Thanks for the responses. The answer for me was pretty simple. I had added the app to a newly created AD, which didn't have an O365 account associated with it. I was logging in as a global admin with an active O365 account on a different AD, but because it was a global admin, it had permissions on all AD instances. SMH.