-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor Web Assembly AAD Auth under .Net 5.0 cannot request multiple tokens #29384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The authentication in progress section of the above, was supposed to be the xaml code from the razor page, the markup is too smart for it's own good. I changed the < characters to # just so it would make it into the issue: #AuthorizeView Policy="OneUser"> |
@snapfisher thanks for the details. Seems like something is going on here. |
Thanks for contacting us. |
This is blocking me at the moment, my app needs to access it's own API and the MS Graph API. Any workarounds? |
@SteveSandersonMS I believe the tags could be reviewed for this issue. Using Microsoft Identity Platform + Graph API for things like avatar images, directory listings, and user management must be a fairly common and documented scenario? I've started comparing the code provided as a resolution to the previous issue (#28226) and trimming it down to the bare essentials. It appears all that's required to get this working for me with the Graph API is to not specify the scopes when adding the graph client to the services collection. This in turn doesn't add anything extra to program.cs in wasm project file. - builder.Services.AddGraphClient("https://graph.microsoft.com/User.Read");
+ builder.Services.AddGraphClient(); The required scopes are also specified in GraphClientExtensions.cs from the docs to authenticate the request. I don't understand the inner workings here enough to say if this is going to work moving forward or bite me later in development but might help someone. |
@javiercn @SteveSandersonMS is there any update to this? |
I'm going to pile on for this. I don't understand the "affected-few" label, as anyone who is using API Management and wants to also speak with the Graph API would have this issue. @javiercn @SteveSandersonMS In my case, it's a requirement as my middleware is just Azure Functions. |
At the time, we had heard very few reports. More are emerging now so I’m updating the label. |
This is also a blocker for me. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
@SteveSandersonMS, any news on this? Like @snapfisher said, this is stopping everyone who is using token authentication for more than one API (.net hosted blazor server api, MS Graph, etc). I have tried following both examples (to no avail) found here |
Re-triaging. |
I've spent a chunk of time investigating this in the past couple of days and I believe it comes down to some changes AAD made to avoid requesting all scopes upfront. This now needs to be done via incremental consent, which is doable, but requires a different approach. I'm going to spend some time to see if I can put an example that accomplishes this through our existing extensibility, but in essence, I believe that requesting the scopes upfront does no longer work. We'll have to revisit the area in .NET 7.0 |
Thanks for contacting us. We're moving this issue to the |
@javiercn I don't know if this helps, but how we went around this is creating a different client for each endpoint for example a graph http client, and an arm http client and we use whichever we need depending on the case, maybe doing that but abstracting it from the user so the user only sees one (or use the same client and just attach different tokens based on the scope being contacted). |
@igalfsg that's more or less what needs to happen. The issue is that Now if you are in a page and need an additional token you need to define how to get that token. Do you provision it during navigation on to the page, or by reacting to an exception, for example when you try to save some data. In that case, do you show a pop-up (pop ups might be blocked)? or do you save the user data, redirect to the IdP and come back. It's doable, it's just much more work now. That said, if you have a sample of what you did in a public repo, I would be interested in looking at how you solved it. Maybe that's an approach we might be willing to take. |
Yeah the additional popup is annoying, if the user only has one account SSO takes care of it but if they have multiple AAD accounts they would get a popup for each scope. Here is a GitHub repo : https://github.com/coding-flamingo/BlazorWasmWithAADAuth |
We addressed this for 7.0, the fix will be available in RC2 |
Thanks @javiercn, Will it work out of the box or is there something we have to do? |
Describe the bug
I see this was reported in #28226, but it was closed without resolution, and the problem definitely exists.
Following instructions here: https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/additional-scenarios?view=aspnetcore-5.0#request-additional-access-tokens
You cannot request multiple tokens under .Net 5.0. The error received is:
Provided value for the input parameter scope is not valid because it contains more than one resource. Scope x y is not valid, where x and y are the scopes I am requesting.
If I request 1 scope only, I can authenticate with no errors.
I have an older blazor wasm application built against .Net Standard 2.1, which follows the same coding instructions/pattern where this does work.
To Reproduce
Program.cs is:
It fails even without attempting token access. Index.razor does not really do much, only ...
Authentication in progress
Please log in with an authorized user
Exceptions (if any)
The error/exception number is AADSTS28000
Further technical details
dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.102
Commit: 71365b4d42
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.102\
Host (useful for support):
Version: 5.0.2
Commit: cb5f173b96
.NET SDKs installed:
1.1.13 [C:\Program Files\dotnet\sdk]
1.1.14 [C:\Program Files\dotnet\sdk]
2.1.617 [C:\Program Files\dotnet\sdk]
2.1.700 [C:\Program Files\dotnet\sdk]
2.1.701 [C:\Program Files\dotnet\sdk]
2.1.812 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
3.1.300 [C:\Program Files\dotnet\sdk]
3.1.405 [C:\Program Files\dotnet\sdk]
5.0.102 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Enterprise 16.8.4
The text was updated successfully, but these errors were encountered: