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?