Auth Token for Sharepoint is working in Postman but when retrieved from Java, the token is throwing exception
Hi, I followed few documentation and did setup an application through Azure AD for accessing Sharepoint files programattically.
As a first step, tried to retrieve access token using below CURL
curl --location 'https://accounts.accesscontrol.windows.net/3cbcc3d3-094d-4006-9849-0d11d61f484d/tokens/OAuth/2'
--header 'Cookie: esctx=PAQABAAEAAAAmoFfGtYxvRrNriQdPKIZ-CO57rHslda6VpKqtfud8rBFgJ8ZTW7mG9l8t9qRu0pmwoEi4xbbNfGBdkCoCeDfXbcT4VLt4N-7l9RMAAWgXrIhzvuEvKEKbQAFRgt7c6_boWxiXJRpX7wLUrdDlGDmTis2QHyLWFAtFDa167RjqbLoMLdxR_1EUUo160Wmhz5wgAA; fpc=Ap5FtJRwR-BKjiUBg-U4NjeEQYJ2AQAAAK2SXt0OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd'
--form 'client_id="b01ccf17-1a3e-4734-a8c6-325809943229@3cbcc3d3-094d-4006-9849-0d11d61f484d"'
--form 'client_secret="iLY8Q~rgNSl~~UGaNrjIKEl8_NBAMK5FGjQq~cmo"'
--form 'grant_type="client_credentials"'
--form 'resource="00000003-0000-0ff1-ce00-000000000000/teams.wal-mart.com@3cbcc3d3-094d-4006-9849-0d11d61f484d"'
--form 'scope="api"'
In Response I got the access token. With the help of access token, I tried accessing this API https://teams.wal-mart.com/sites/ChinaPIPLRemediation/_api/web/GetFolderByServerRelativeUrl('Shared Documents') and able to get the response in POSTMAN.
However when I do the same set of actions through Java Program, If I use the generated token for accessing other APIs it is providing me following exception
Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException