Authenticate to Azure SDK for JavaScript using oAuth token from Azure AD
See original GitHub issue- I’m writing a vanilla JavaScript application using Express.js and Node.js version 14.10.
- I’m using the Microsoft Authentication Library (MSAL) for JS to log into Azure Active Directory
Question
How do I authenticate to Azure Resource Management APIs using an oAuth token that I received from Azure Active Directory (AAD)? I can’t find any constructor to feed the oAuth token into, so I can obtain a ServiceCredentials
object.
All of the examples are useless, because they show how to perform an “interactive login,” which isn’t what I want.
I already have a valid oAuth token. How do I use it in the Azure SDK for JS?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Azure Identity client library for JavaScript | Microsoft Learn
The Azure Identity library provides Azure Active Directory (Azure AD) token authentication through a set of convenient TokenCredential ...
Read more >Authenticate Using Microsoft with JavaScript | Firebase - Google
You can let your users authenticate with Firebase using OAuth providers like Microsoft Azure Active Directory by integrating generic OAuth Login into your ......
Read more >Azure Identity SDK (JS) How to Authenticate to User's Azure ...
Using access token, you can retrieve user's info or access any other resource in Azure tenant. The InteractiveBrowserCredential uses ...
Read more >Authenticating to Azure services with Azure AD and MSAL.js
As more and more services in Azure support modern & managed authentication using Azure Active Directory, you may begin to wonder, ...
Read more >Microsoft Authentication Library for JavaScript (MSAL.js)
through Azure AD B2C service. It also enables your app to get tokens to access Microsoft Cloud services such as Microsoft Graph. npm...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey Trevor, long time no see!
@ramya-rao-a’s most recent suggestion is the simplest way to go, you’ll want to create a simple class or object that implements
ServiceClientCredentials
to wrap the token you get back from MSAL. Here’s a full example of how you’d do that in JavaScript:You can then pass
creds
into the constructor of the Azure SDK client library you’re using.Looks like that solution worked for you @pcgeek86, thanks for reporting the issue.
@daviwil, As discussed offline, can you update the readme for
@azure/ms-rest-nodeauth
to include a note on the above solution if the one already has an access token? Logged https://github.com/Azure/ms-rest-nodeauth/issues/103