I have built a Node.js web app hosted on Azure with Azure AD authentication. How can I obtain the bearer token from the client's session to send authenticated requests to another app service in Azure also protected by the same Azure AD?
1 Answer
When your user get authenticated via AAD and redirect to your web app hosted on Azure. Your can get the HTTP header of this request, you can find the access_token is stored in the header param X-Ms-Token-Aad-Id-Token.
Then you can store this token in session or in cookie for your custom requirement. And you set this token in the header of the request against to your other web apps in the same AAD.
The token should be set in the Authorization param in headers and the value format should be bearer <token>.
Any further concern, please feel free let me know.