-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor webassembly msal does not work with scopes on multiple resources #33241
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
@JohanArleth thanks for contacting us. Check out the docs for how to do this here |
Those are the docs I've been following. |
@JohanArleth no problem, thanks for the details. Is this AAD or AAD B2C? Seems like AAD? |
Thanks for contacting us. We're moving this issue to the |
It is AAD |
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. |
Just like to bump this -- really need this fixed for Blazor Wasm to be viable in our corp environment. |
@tomreich If you grant admin consent on the scopes you need, you can remove default scopes from the code, and there will be no consent popups when requesting the scopes after login. If you are inside your corp environment there is probably not any need for the users to manually consent each scope. That said it would be really nice if this could get some attention |
@JohanArleth Thanks, unfortunately I do not have permission to grant admin consent. |
I've just run into this issue myself. API scope and graph scope in one Blazor WASM app. With some tinkering with named http clients and providers, I've got the app running once it's deployed, but when debugging on launch of the application, and once trying to retrieve data via the graph client, an
|
Describe the bug
Using the blazor webassambly msal libray it's possible to get tokens for scopes on one resource, but as soon as you attempt to get additional scopes on another resouce, you into issues with multiple resources:
AADSTS28000: Provided value for the input parameter scope is not valid because it contains more than one resource.
This error itself is of course correct, but the library should not be trying to get a token for both the default scope and the new scopes.
MSAL.NET covers this scenario: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-user-gets-consent-for-multiple-resources
Related stackoverflows:
https://stackoverflow.com/questions/60754751/blazor-webassembly-standalone-access-multiple-aad-protected-apis
https://stackoverflow.com/questions/67788030/how-to-handle-tokens-for-multiple-resources-in-blazor-webassembly-msal
To Reproduce
Example repo:
https://github.com/JohanArleth/MsalMultipleDomains
To get it running, fill out the appsettings with clientid, tenantid and a scope that is not from graph.
Run the example and you should automatically be asked to login. So far so good.
There is then a button "Get graph scopes" which will do the following:
Once you have consented to these new scopes, and hit the callback to the application, you will get the multiple resources error and land on the page for problem with login.
This is only an issue when you have to provide consent, so subsequent attempts will work, until you revoke your consent and clear site data.
This can be avoided by not setting any default scopes, but this then means that you will have to trigger extra consent dialogs.
Exceptions (if any)
Further technical details
dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.300
Commit: 2e0c8c940e
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.300\
Host (useful for support):
Version: 5.0.6
Commit: 478b2f8c0e
.NET SDKs installed:
5.0.300 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
The text was updated successfully, but these errors were encountered: