2

I'm developing a Web assembly application that is calling a Web API. The web api is authenticated through OAUTH2, and the Identity provider is actually Azure AD B2C. The process works fine while using MSAL library to authenticate my users and pass th access token to the backend on Web assembly. But I'd like to use oidc client instead of Msal to get the possibility to provide more authentication scenarii...

I have the possibility to authenticate my users on the same apps with configuring Oidc:

            builder.Services.AddOidcAuthentication(options =>
            {
                options.ProviderOptions.Authority = settings.Authority;
                options.ProviderOptions.MetadataUrl = settings.MetadataUrl;
                options.ProviderOptions.ClientId = settings.ClientId;

                options.ProviderOptions.DefaultScopes.Clear();
                options.ProviderOptions.DefaultScopes.Add("openid");
                options.ProviderOptions.DefaultScopes.Add("profile");
                options.ProviderOptions.DefaultScopes.Add(settings.Scope);

                options.ProviderOptions.ResponseType = "id_token";
            });

But this fails when adding the BaseAddressAuthorizationMessageHandler to my HttpClient to pass the access token to the API (obviously because I haven't the token). The error message at this step is :

An exception occurred executing JS interop: The JSON value could not be converted to System.DateTimeOffset. Path: $.token.expires | LineNumber: 0 | BytePositionInLine: 170.. See InnerException for more details.
 ---> System.Text.Json.JsonException: The JSON value could not be converted to System.DateTimeOffset. Path: $.token.expires | LineNumber: 0 | BytePositionInLine: 170.
 ---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a string.

After adding the token to the response type : token id_token, I have another issue.. The Web assembly is failing. The page block at authentication/login-callback and the tokens (that are correctly present) seems to no beeing handled.

Has anyone ever encountered this kind of problem?

2
  • 1
    After some searches, it seems that the first issue I'm encountering is due to a bug in the library taht should be fixed in 6.0.2 (no released yet). See: github.com/dotnet/aspnetcore/issues/39311 Commented Jan 26, 2022 at 8:30
  • Microsoft.AspNetCore.Components.WebAssembly is now at 6.0.3 -- but still this issue exists for Azure AD B2C Commented Apr 5, 2022 at 7:09

1 Answer 1

1

Adding Kévin BEAUGRAND Comment as an answer which will be helpful for the other community members who are having related issue.

As per the github link the token issue for blazor application in Azure b2c will be fixed with the New Patch Release of 6.0.2 version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.