0

I am creating Bearer token from Azure AD using the following

URL - https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token

Request Method - POST

Payload -

{
"client_id": "",
"client_secret": "",
"scope: "",
"grant_type": "client_credentials"
}

This is generating access token as expected.

My requirement is I want to pass an extra param when generating token like "testId" (dynamic value) along with client id, secret, scope & grant_type while creating token and fetch the testId value when validating or verifying the token.

I tried adding a custom claim in azure portal and fetched it when validating but the limitation here is that we need to hard-code the value in azure portal.

Do we have any other way to complete my requirement?

Any help is much appreciated.

Akki
  • 107
  • 1
  • 5
  • 14

1 Answers1

0

There is a state parameter in the Authorization Code Flow that you can set in the request to get the token, which is then returned in the response.

This doesn't make sense for the Client Credentials Flow since the token request is a direct request/response instead of a redirect like for the Auth Code Flow or Implicit Flow.

PramodValavala
  • 6,026
  • 1
  • 11
  • 30
  • I want to pass the custom param for token generation, this is the url https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token what you've shared is for authorization with login – Akki Mar 24 '23 at 20:43