You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe this is actually a bug within the MSAL library. I have raised an issue on that related repo but it's pretty silent there. After picking this issue back up today I've been looking through the codebase and AddMsalAuthentication, as a call, actually lives in this repo so On the off-chance the issue is here (maybe it's not passing through the config to the MSAL library), I'm going to raise it here as well. At the very least I hope to drum up some attention on the MSAL issue.
The issue on the MSAL board accurately reproduces it, copied from that issue for ease:
I am in a Blazor Wasm application. The End-State that I'm trying to get to is on application login, scopes are provided such that 1st and 3rd party resources are accessible using the single login without any future redirecting. In this example I am trying to access a 1st party API and a 3rd party Azure resource (a storage account).
I am using a custom TokenCredential implementation that uses the IAccessTokenProvider to request a token with the Azure service scope, and creates an Azure.Core.AccessToken that can be used with the Azure.Storage.Blobs library.
I've tried various combinations of DefaultAccessTokenScopes and AdditionalScopesToConsent. AdditionalScopesToConsent doesn't seem to do anything in terms of "prepping" the scopes for future use. I'm not even sure it's purpose really, it seems to do nothing.
Depending on which scope is set as the DefaultAccessTokenScopes will dictate which service works.
I'm happy to provide any additional context as needed. I've spent the last 2 days both trying to work out the combinations based upon my knowledge, and using the internet to try and work out how I can use the SSO into the blazor app to work with multiple external resources.
N.B. All external resources use the same Microsoft Entra source. Users are configured in the IAM of the related resources.
usingAzure.Core;usingMicrosoft.AspNetCore.Components.WebAssembly.Authentication;usingAzureAccessToken=Azure.Core.AccessToken;usingWasmAccessToken=Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessToken;namespaceTokenExample;publicclassWasmTokenCredential:TokenCredential{privatereadonlyIAccessTokenProvider_accessTokenProvider;publicWasmTokenCredential(IAccessTokenProvideraccessTokenProvider){_accessTokenProvider=accessTokenProvider;}publicoverrideAzureAccessTokenGetToken(TokenRequestContextrequestContext,CancellationTokencancellationToken)=>thrownewNotSupportedException("Cannot use synchronous token acquisition in a WebAssembly environment.");publicoverrideasyncValueTask<AzureAccessToken>GetTokenAsync(TokenRequestContextrequestContext,CancellationTokencancellationToken)=>FromWasmResult(await_accessTokenProvider.RequestAccessToken(new(){Scopes=[.. requestContext.Scopes]}));privateAzureAccessTokenFromWasmResult(AccessTokenResulttokenResult){if(tokenResult.TryGetToken(outWasmAccessToken?accessToken)==false){thrownewInvalidOperationException("Failed to obtain an access token.");}returnnewAzureAccessToken(accessToken.Value,accessToken.Expires);}}
On initial login in blazor WebAssembly, no further login prompts are required for accessing other authorized Azure Resources. (in this example, A blob storage)
.NET Version
9.0.203
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Describe the bug
I believe this is actually a bug within the MSAL library. I have raised an issue on that related repo but it's pretty silent there. After picking this issue back up today I've been looking through the codebase and AddMsalAuthentication, as a call, actually lives in this repo so On the off-chance the issue is here (maybe it's not passing through the config to the MSAL library), I'm going to raise it here as well. At the very least I hope to drum up some attention on the MSAL issue.
The issue on the MSAL board accurately reproduces it, copied from that issue for ease:
I am in a Blazor Wasm application. The End-State that I'm trying to get to is on application login, scopes are provided such that 1st and 3rd party resources are accessible using the single login without any future redirecting. In this example I am trying to access a 1st party API and a 3rd party Azure resource (a storage account).
I am using a custom
TokenCredential
implementation that uses theIAccessTokenProvider
to request a token with the Azure service scope, and creates anAzure.Core.AccessToken
that can be used with theAzure.Storage.Blobs
library.I've tried various combinations of
DefaultAccessTokenScopes
andAdditionalScopesToConsent
. AdditionalScopesToConsent doesn't seem to do anything in terms of "prepping" the scopes for future use. I'm not even sure it's purpose really, it seems to do nothing.Depending on which scope is set as the
DefaultAccessTokenScopes
will dictate which service works.I'm happy to provide any additional context as needed. I've spent the last 2 days both trying to work out the combinations based upon my knowledge, and using the internet to try and work out how I can use the SSO into the blazor app to work with multiple external resources.
N.B. All external resources use the same Microsoft Entra source. Users are configured in the IAM of the related resources.
Relevant code snippets
Program.cs
WasmTokenCredential.cs
BlobService.cs
appsettings.json
Expected Behavior
On initial login in blazor WebAssembly, no further login prompts are required for accessing other authorized Azure Resources. (in this example, A blob storage)
.NET Version
9.0.203
The text was updated successfully, but these errors were encountered: