[Documentation] Authentication documentation error for azure-graph sdk using interactive authentication
See original GitHub issueError Observed
Documentation/Authentication.md references tokenAudience
of graph
, but it should be https://graph.microsoft.com
. Using graph
will result in the error below. Using Service Principal Authentication with the subscription and tenant works fine.
AADSTS500011 The resource principal named 'graph' was not found in the tenant named [currentTenantID].
Recommended Fix
Update the following:
const AzureGraphClient = require('azure-graph');
const MsRestAzure = require('ms-rest-azure');
const options = {
tokenAudience: 'graph',
domain: '<tenantId>'
};
MsRestAzure.interactiveLogin(options, (err, credentials) => {
if (err) throw err;
let graphClient = AzureGraphClient(credentials, '<tenantId>');
// ..use the client instance to manage service resources.
});
To:
const AzureGraphClient = require('azure-graph');
const MsRestAzure = require('ms-rest-azure');
const options = {
tokenAudience: 'https://graph.microsoft.com',
domain: '<tenantId>'
};
MsRestAzure.interactiveLogin(options, (err, credentials) => {
if (err) throw err;
let graphClient = AzureGraphClient(credentials, '<tenantId>');
// ..use the client instance to manage service resources.
});
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Resolve Microsoft Graph authorization errors
This error often means that the access token may be missing in the HTTP authenticate request header or that the token is invalid...
Read more >Unattended authentication against the Microsoft Graph API ...
Providing a username and password in the form of a PowerShell credential object is not sufficient in this scenario, as the API is...
Read more >AzureGraph: Simple Interface to 'Microsoft Graph'
Details create_graph_login creates a login client to authenticate with Microsoft Graph, using the sup- plied arguments. The authentication token ...
Read more >Using the AzureGraph package to pull Microsoft Teams usage ...
See the authentication scenarios vignette in the latest release of the ... for interactive use, and it's possible that the Graph API doesn't ......
Read more >Calling Azure REST API via curl - Davide Mauri - Medium
Azure API security, and thus authentication (which is based on OAuth2) is a pretty broad topic as you can see from the long...
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
Closing as the docs are now updated with #5187
Thanks for logging the issue and working with us @joshlarsen!
@joshlarsen Using
ms-rest-azure
is not the problem here. My question was around using theazure-graph
package.The newer Microsoft Graph API is recommended over the older Azure AD Graph API.
The
azure-graph
package is for the latter. The@microsoft/microsoft-graph-client package is for the former.Regardless, since you don’t have control over the tool that uses
azure-graph
I believe you have no control over moving to Microsoft Graph either.@willmtemple, I believe we can take the path of least resistance here and just update the docs like @joshlarsen suggested.