Home > Back-end >  How to generate bearer token via azure data factory
How to generate bearer token via azure data factory

Time:01-26

I followed this blog for generating bearer token.

I have an API like this https://login.microsoftonline.com/<tenantid>/oauth2/token.

I tested it in postman it's working but it is not working in ADF.

Error message

"error": "invalid request"
"error description": "xxxx: The 'resource' request parameter is not supported. \r\nTrace ID: xxxxx\rnCorrelation ID: xxxx\r\nTimestamp: xxxx"
"error codes": [
901002

CodePudding user response:

Yes ,you can use both resource and scope depending upon endpoint.

If you are using endpoint with oauth2/token: https://login.microsoftonline.com/<tenant id>/oauth2/token

You need to use resource=https://graph.microsoft.com/ inside the body

Body: grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>&resource=https://graph.microsoft.com/

enter image description here

If you are using oauth2/v2.0/token endpoint https://login.microsoftonline.com/<tenant id>/oauth2/v2.0/token

You need to use scope:

Body: grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>&scope=https://graph.microsoft.com/.default

enter image description here

The pipeline successfully executed got the token:

enter image description here

  • Related