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.

[FEATURE REQ] : Passing scopes to EnableTokenAcquisitionToCallDownstreamApi() vs AddMicrosoftGraph()

See original GitHub issue

We need to streamline and document the right way to pass scopes to EnableTokenAcquisitionToCallDownstreamApi() vs AddMicrosoftGraph()

What is the difference between passing scopes to EnableTokenAcquisitionToCallDownstreamApi vs AddMicrosoftGraph Which one should be used?

            //Sign -in users with the Microsoft identity platform(MSAL)
            services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"))
                .EnableTokenAcquisitionToCallDownstreamApi()
                .AddMicrosoftGraph(defaultScopes: "User.Read User.ReadBasic.All")
                .AddInMemoryTokenCaches();
            services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"))
                .EnableTokenAcquisitionToCallDownstreamApi(initialScopes: new string[] { "User.Read", "User.ReadBasic.All" })
                .AddMicrosoftGraph()
                .AddInMemoryTokenCaches();

Can we change AddMicrosoftGraph() to accept an array of scopes instead of scopes separated by space?

.AddMicrosoftGraph(defaultScopes: new string[] { "User.Read", "User.ReadBasic.All" })

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
jmprieurcommented, Jan 21, 2021

Thanks @KalyanChanumolu-MSFT for the update We can have a override to AddMicrosoftGraph to accept an array of scopes (even with a params)

@jennyf19 proposing to do something about this one.

1reaction
jmprieurcommented, Jan 20, 2021

Adding an enhancement label, so that we try to register the initialScopes if not passed to EnableTokenAcquisitionToCallDownstreamApi (if possible)

Read more comments on GitHub >

github_iconTop Results From Across the Web

A web API that calls web APIs: Code configuration
A web API needs to acquire a token for the downstream API. Specify it by adding the .EnableTokenAcquisitionToCallDownstreamApi() line after .
Read more >
asp.net core - Unable to set scopes with ...
EnableTokenAcquisitionToCallDownstreamApi (initialScopes) .AddMicrosoftGraph();. However, since I'm working on an API controller only, and not a ...
Read more >
Implementing OAuth 2.0 On-Behalf-Of Flow for Dataverse ...
In this flow, the objective is to propagate the delegated user identity and permissions throughout the entire request chain.
Read more >
Using Microsoft Graph API delegated clients in ASP.NET Core
The AddMicrosoftGraph method is used to add the required scopes for your Graph API calls. The AddMicrosoftIdentityWebAppAuthentication method is ...
Read more >
Addinmemorytokencaches get token. Web). In-memory ...
I had issues like this when trying to add Azure AD (Microsoft) authentication to my ASP. The MSAL library for . The project...
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