Reputation: 302
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?
Upvotes: 2
Views: 836
Reputation: 2440
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.
Upvotes: 1