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?