SharePoint API authorization token

%3CLINGO-SUB%20id%3D%22lingo-sub-559362%22%20slang%3D%22en-US%22%3ESharePoint%20API%20authorization%20token%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-559362%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20attempting%20to%20build%20an%20integration%20between%20the%20product%20the%20company%20I%20work%20for%20sells%2C%20and%20SharePoint.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20purpose%20of%20the%20app%20is%20to%20create%20a%20folder%20or%20site%20structure%20based%20on%20data%2C%20and%20retrieve%20links%20to%20the%20files%20users%20upload%20to%20that%20structure%20so%20we%20can%20redirect%20people%20to%20them.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20admin%20that%20takes%20care%20of%20our%20office365%20set%20up%20the%20app%2C%20and%20I%20can%20get%20access%20tokens%2C%20but%20I%20get%20%22Exception%20of%20type%20'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException'%20was%20thrown.%22%20or%20%22%3CSPAN%20class%3D%22hljs-title%22%3EUnsupported%3C%2FSPAN%3E%3CSPAN%3E%20app%20only%20token.%22%26nbsp%3B%3C%2FSPAN%3Eas%20a%20response.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20how%20I%20am%20getting%20the%20token%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EURL%3A%20%3CA%20href%3D%22https%3A%2F%2Flogin.microsoftonline.com%2F%26lt%3B%26lt%3Btenant%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Flogin.microsoftonline.com%2F%26lt%3B%3CTENANT%3E%3C%2FTENANT%3E%3C%2FA%3E%20ID%26gt%3B%26gt%3B%2Foauth2%2Fv2.0%2Ftoken%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHeaders%3A%20Content-Type%3A%26nbsp%3Bapplication%2Fx-www-form-urlencoded%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EBody%20(without%20URL%20encoding)%3A%20client_id%3D%26lt%3B%3CCLIENT%20id%3D%22%22%3E%26gt%3B%26amp%3Bscope%3D%3CA%20href%3D%22https%3A%2F%2FCompanyName.sharepoint.com%2F.default%26amp%3Bclient_secret%3D%26lt%3B%26lt%3Bclient%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2FCompanyName.sharepoint.com%2F.default%26amp%3Bclient_secret%3D%26lt%3B%3CCLIENT%3E%3C%2FCLIENT%3E%3C%2FA%3E%20secret%26gt%3B%26gt%3B%26amp%3Bgrant_type%3Dclient_credentials%3C%2FCLIENT%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERequest%20Type%3A%20POST%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20an%20example%20of%20what%20I%20am%20attempting%20to%20send%20(a%20request%20to%20get%20a%20list%20of%20files%20in%20a%20folder)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EURL%3A%20%3CA%20href%3D%22http%3A%2F%2FCompanyName.sharepoint.com%2F_api%2Fweb%2FGetFolderByServerRelativeUrl('%2FFolder1')%2FFiles%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2FCompanyName.sharepoint.com%2F_api%2Fweb%2FGetFolderByServerRelativeUrl('%2FFolder1')%2FFiles%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHeaders%3A%26nbsp%3BAuthorization%3A%20bearer%20%26lt%3B%3CACCESS%20token%3D%22%22%3E%26gt%3B%3C%2FACCESS%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Accept%3A%26nbsp%3Bapplication%2Fjson%3Bodata%3Dverbose%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERequest%20Type%3A%20GET%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-559362%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ephp%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
New Contributor

I am attempting to build an integration between the product the company I work for sells, and SharePoint. 

 

The purpose of the app is to create a folder or site structure based on data, and retrieve links to the files users upload to that structure so we can redirect people to them.

 

The admin that takes care of our office365 set up the app, and I can get access tokens, but I get "Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown." or "Unsupported app only token." as a response.

 

Here is how I am getting the token:

 

URL: https://login.microsoftonline.com/<<tenant ID>>/oauth2/v2.0/token

 

Headers: Content-Type: application/x-www-form-urlencoded

 

Body (without URL encoding): client_id=<<client ID>>&scope=https://CompanyName.sharepoint.com/.default&client_secret=<<client secret>>&grant_type=client_credentials

 

Request Type: POST

 

Here is an example of what I am attempting to send (a request to get a list of files in a folder):

 

URL: http://CompanyName.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/Folder1')/Files

 

Headers: Authorization: bearer <<Access Token>>

          Accept: application/json;odata=verbose

 

Request Type: GET

0 Replies