6
votes

I have a client app that uses the Office 365 SharePoint preview API. Recently (as of October 2014), Microsoft published version 1.0 of that API. The authentication steps used with the preview API no longer work with version 1.0.

To demonstrate the problem I have created a short node.js script. The script does the following:

  • Authorizes by launching a browser. Gives a redirect URL to localhost and launches a server to catch the redirect post-authorization
  • POST to https://login.windows.net/common/oauth2/token to get an access token
  • GET to the Office 365 discovery service to get the SharePoint API endpoint
  • POST to https://login.windows.net/common/oauth2/token with a refresh token to get a new access token
  • GET to the SharePoint API endpoint to get a list of files

The script can be used with the preview API and version 1.0 of the API. It is able to get a JSON list of files from the preview API, but fails with the following for version 1.0 (on the last call):

{
    "error": {
        "code": "-2147024891, System.UnauthorizedAccessException",
        "message": "Access denied. You do not have permission to perform this action or access this resource."
    }
}

Does anybody see anything wrong with the sequence of calls?

Please take a look at the sample script for more details.

2

2 Answers

0
votes

Thanks for getting in touch and we appreciate the feedback. A fix is being rolled out to address non-admin's access to Files/Folders through Files API. If you are still in the development/exploration phase, you could consider following measures to unblock:

a. Temporarily add the user as the admin on the my site host web

b. Temporarily get AllSites permissions for the app

I'll update this thread once the issue is patched in Production, which should happen very soon.

0
votes

In looking at your scripts, it looks like you are using a hard coded resource ID ("Microsoft.SharePoint"), when I believe the new one is ("domain-my.sharepoint.com"). If using multi-tenant, it will be dynamic and available from the discovery call and likely the id you should use each time. If you have single tenant, then I suppose you could hard code it.