Office 365 OneDrive REST API - "invalid_client"

I am trying to access the new 365 REST APIs. (As described here ).

I am using Postman client to send request.

I registered my app with Azure AD and gave it full permissions for "Office 365 SharePoint Online".

I can successfully get an authorization token using the clientId generated in Azure AD.

However, when I try to list files using an access token, I get an error.

------------------
RESOURCE HTTP GET:
------------------
URL: https://<OUR_DOMAIN>-my.sharepoint.com/personal/<user_domain>/_api/Files
HEADER: Authorization: Bearer <access token>

Response:

3001000;reason="There has been an error authenticating the request.";category="invalid_client"

      

What could be causing this problem?

+3


source to share


2 answers


Not sure what steps you tried to use to solve this problem, so it is difficult for you to help you here. I just finished writing more detailed instructions on how to register your OneDrive for Business calling app. It is long and difficult now, but we are working to improve the situation in the future.

You can find out the details on how to auth here: https://dev.onedrive.com/auth/aad_oauth.htm



Make sure you are not asking for too many permissions, as this will require your application to be authenticated by the administrator and not the end user. For most applications, you can simply use the My Files permission scopes, which can be accepted directly by the user of your application.

If you post more information about what calls you make, answers and app settings in AAD, I can help more.

+1


source


You may have used different resources.

Check if the resource you used to get the access token is the same as you are requesting to get the files.

eg:

If the resource you mentioned during the access token request would be: https://tenant-my.sharepoint.com/ "



Then you need to make a request for the same resource to access the files :: " https://tenant-my.sharepoint.com/ _api / v2.0 / drive / root / children"

The above query gives a list of root children.

  • tenant -> the domain name that has been registered with your organization.

Follow this documentation for further api access

+1


source







All Articles