0

I want to create first time a WebPart for SharePoint Online, where I need to use the MSGraphClientV3. I'm struggeling around with the authenication. I know the articles

https://learn.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph

etc. But in all articles, I'm wondering how the MSGraphClientV3 knows how to connect to which tennant and which app registration. As far as I know, I need to create an app registration and set there the API permissions i.e. to User.Read.All or similar. In all examples from Microsoft, I found only these codes:

this.context.msGraphClientFactory
  .getClient('3')
  .then((client: MSGraphClientV3): void => {
    // get information about the current user from the Microsoft Graph
    client
      .api('/me')
      .get((error, response: any, rawResponse?: any) => {
        // handle the response
    });
  });

But how does the msGraphClientFactory know to connect to which tennant and which app registration. In all examples the code above is given as example, but I do not see there any Id's. Can someone enlighten me?

1 Answer 1

0

It's simply the wonderful magic of the SharePoint Framework handling this authentication on your behalf and using the current users context to authenticate. You don't need to think of it.

If you look at the article you provided (https://learn.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph) under known issues, you'll see that it refers to the MSGraphClient using the implicit authentication flow. If you want to know more about that you could take a look here: https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-implicit-grant-flow to get a better understanding of how it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.