question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Documentation] Authentication documentation error for azure-graph sdk using interactive authentication

See original GitHub issue

Error 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].
Screenshot 2020-06-09 10 24 58

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:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ramya-rao-acommented, Jul 27, 2020

Closing as the docs are now updated with #5187

Thanks for logging the issue and working with us @joshlarsen!

0reactions
ramya-rao-acommented, Jul 23, 2020

@joshlarsen Using ms-rest-azure is not the problem here. My question was around using the azure-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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found