API returning a 401 error with message "Requested API is not supported in Admin On-Behalf-Of mode"

Viewed 209

Getting "Requested API is not supported in Admin On-Behalf-Of mode" error while running teams API even though admin granted consent

"https://graph.microsoft.com/v1.0/me/joinedTeams" API returning 401 error with message as shown below

{ "error": { "code": "Unauthorized", "message": "Requested API is not supported in Admin On-Behalf-Of mode.", "innerError": { "date": "2022-08-30T08:14:51", "request-id": "8acdeb30-a9c5-434c-bfcf-ca9cbd383cbd", "client-request-id": "8acdeb30-a9c5-434c-bfcf-ca9cbd383cbd" } } }

Below are the permissions granted on app registration side

enter image description here

Below are the permissions granted on tenant side

enter image description here

2 Answers

First of all you can check your scopes by decoding access token in https://jwt.ms/ , make sure you have Team.ReadBasic.All, TeamSettings.Read.All permission added (screenshot 1). If its not added then you can also check if your admin granted consent or not , by checking azure portal (Screenshot 2)

Screenshot 1

One of the following permissions is required to call this API enter image description here

Screenshot 2

if your admin granted consent ? You should use an Azure AD admin account to do this. The the Status will become "Granted for {your tenant}". , enter image description here

We added Publisher domain and MPN id for our app in the 'Branding & Properties' section. We also created a new 'client secret' and used it. Then the teams and channels list APIs started working.

Related