We´re trying to get the token for Oauth using the official docs request:
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id='my client id'
&scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
&code='my auth code obtained in previous auth request'
&grant_type=authorization_code
&client_secret='my client secret'
But when we make the request it responds with this error:
AADSTS65001: The user or administrator has not consented to use the application with ID 'mya app id' named 'my app name'. Send an interactive authorization request for this user and resource"
Thing is, we already gave them this permissions on Azure portal AD and app registration even with the admin consent but still:
is there any permission missing there ?, any clue about this ?
1) Go to Azure portal -> Azure AD -> App registrations -> Your app -> Authentication -> check the below options -> Save.
2) To resolve the error, make sure to grant below Api permissions along with permissions you have given:
3) To get the token, I used postman by giving parameters like below:
4) I successfully got the token like below:
After every change, try refreshing your Azure Portal and Postman.
For more in detail, please refer below links:
Microsoft identity platform and OAuth 2.0 authorization code flow - Microsoft identity platform | Microsoft Docs
azure - AADSTS65001: The user or administrator has not consented to use the application with ID ' - Stack Overflow