I have been struggling to call SharePoint Rest API from Postman. The site is using ADFS Authentication & registered on ADFS using URN.
By following multiple Articles, I first Registered an App in SharePoint using Appreg.aspx page where I got the Client ID: 2526bc7a-2e0e-4d92-a5ac-69707ac7aeb2 & a Secret also.
I have granted permissions to this App:
Appinv permissions:
https://facilitiesuat.engro.com/_layouts/15/AppInv.aspx
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl"/>
</AppPermissionRequests>
Then I used this Client ID to register this App for API call on ADFS server by following the below steps:
Steps to Register Client ID in ADFS via GUI (Graphical User Interface) Since you want to register the client without using PowerShell, follow these GUI-based steps to register a client application in ADFS. Step 2: Add a New Client Application
- In the left panel, expand AD FS → Application Groups.
- Right-click on Application Groups and select Add Application Group.
- In the Add Application Group Wizard: o Name: Enter a name (e.g., "Facilities API Client"). o Template: Select Server application accessing a web API. o Click Next. Step 3: Configure the Client ID
- Client Identifier: o Click Add and enter the Client ID you got from SharePoint. o Click Next.
- Redirect URI: o Click Add and enter: https://facilitiesuat.engro.com/_layouts/15/OAuthAuthorize.aspx o Click Next. Step 4: Configure Application Permissions
- Select Access Control Policy: Choose Permit everyone
- Web API: o In "Configure Web API", click Add. o Enter the resource identifier as: https://facilitiesuat.engro.com o Click Next. Step 5: Generate Client Secret
- On the Client Secret page, click Generate Secret.
- Copy the Client Secret and save it safely (it won’t be shown again).
- Click Next, then Finish.
Then I got another Client ID and secret from ADFS, which I used to get Access token in PostMan:
Now I am passing this Access token to call GetItems API but getting the same error from multiple solution tries:
{"error":"invalid_client","error_description":"Invalid audience Uri 'https:\/\/facilitiesuat.engro.com\/'."}
Any help here would be highly appreciated.
Thank you