Unable to Authenticate Azure AD Function App in PostMan

Viewed 182

I have enabled Azure AD for the function APP. AzureIdentity is my Function APP name. Azure Function I am using "\oauth2\token"

Get:
https://login.microsoftonline.com/{my tenant ID}/oauth2/token

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

grant_type:client_credentials
resource:https://management.azure.com/
client_id:04e17699-64cd-42ec-96ec-23be345ef6ed
client_secret:{My secret}

Get Authentication PostMan I am getting bearer token on Get request and passing it to the Function, but I am getting 401 Authentication error as below. Not sure where I am doing wrong. Function APP

Please help how can I authenticate the function, Thank you.

2 Answers

'resource' parameter is not required, instead use 'scope' parameter

Scope here is my custom app ID which has a custom application role defined.

scope ==> "04e17699-64cd-42ec-96ec-23be345ef6ed/.default"

enter image description here

enter image description here

I tried to reproduce the same in my environment and got the same error as below:

enter image description here To resolve the error, make use of V2 endpoint to generate the token like below:

enter image description here

Using the above generated access token, I am able to call the Function app successfully like below:

enter image description here

Make sure to give the code you get in function URL as a value to x-function-key parameter.

enter image description here

Related