Blazor WASM Hosted Azure AD Application crashes after receiving Token

David Reckner 0 Reputation points
2023-03-16T02:06:53.79+00:00

I have a Blazor WASM Hosted App that is using Azure Active Directory using the MSAL nuget package. During the login process, after receiving the access token, the application crashes with a JSON Parsing error. Have worked through the online walk through multiple times.

Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyJ9.eyJhdWQiOiJiMjNmNTY3OC03YTFlLTQ5NWMtYjk4NS0yZDYwMTg3YTVlM2IiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vZDExMDIyNjYtY2I1OS00NzZjLThkNWYtYjlkY2I5YjQyNWJjL3YyLjAiLCJpYXQiOjE2Nzg5MzE2NTMsIm5iZiI6MTY3ODkzMTY1MywiZXhwIjoxNjc4OTM1NTUzLCJuYW1lIjoiRGF2aWQgUmVja25lciIsIm5vbmNlIjoiMmExNGZjZDEtMTIyMC00YTRhLTgyZDctYTg0YmQzMzJkOTgyIiwib2lkIjoiYTMyMmFkNjQtOWE0Yy00ZDYwLTlhYTctMzkxMTJiZjkwOTYzIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiZHJlY2tuZXJAcmVja25lci5jb20iLCJyaCI6IjAuQVJnQVppSVEwVm5MYkVlTlg3bmN1YlFsdkhoV1A3SWVlbHhKdVlVdFlCaDZYanNZQURZLiIsInJvbGVzIjpbIkZpbmFuY2UiXSwic3ViIjoiMDNGLTJhTHVJb1VFR0Mzek14SEpBOHVUUk80eW00d1RKOFM2ZXhXWnJPWSIsInRpZCI6ImQxMTAyMjY2LWNiNTktNDc2Yy04ZDVmLWI5ZGNiOWI0MjViYyIsInV0aSI6ImNwUWVHMmJJUUUyb1hkRm14azRvQVEiLCJ2ZXIiOiIyLjAifQ.QL0yCpMFO8uxES4dpTWiMSKhiPlUru7DGBOa0bvyt42X-8S-7PwCOm3j3TGZiHDcBEeUjde5SjUa9wOSQyAHZMPMaTrEnYaImysHEEkaFUZSPQILcLMiPPQI15UyCGGhQ4tbkj1EssfdxHfUnnlhR9KqD09gXWXLr70ZfNCx2ecJSd1L4po6zNFyIrCLU6XtC_948vd8bq-7k7uURRAxSVs0r-k5DBJHKnCStTlqT7j6aHlYgRm_-mmM8Xk_ZeIwIzu0GgvVKXiO-7znrDkGjgaUQ9a3Z73fQjqnYey9EXLSbdz2uiuXd654xcAV7e7HG_Xhfb3F17nsdp8OreurcQ

Exception:

 Unhandled exception rendering component:  An exception occurred executing JS interop: The JSON value could not be converted to Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState]. Path: $ | LineNumber: 0 | BytePositionInLine: 4.. See InnerException for more details.       
 Microsoft.JSInterop.JSException: An exception occurred executing JS interop: The JSON value could not be converted to Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState]. Path: $ | LineNumber: 0 | BytePositionInLine: 4.. See InnerException for more details.
 ---> System.Text.Json.JsonException: The JSON value could not be converted to Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState]. Path: $ | LineNumber: 0 | BytePositionInLine: 4.
   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, InternalRemoteAuthenticationResult`1& value)
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[Object](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.Read[Object](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at Microsoft.JSInterop.JSRuntime.EndInvokeJS(Int64 taskId, Boolean succeeded, Utf8JsonReader& jsonReader)
   --- End of inner exception stack trace ---
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalRemoteAuthenticationResult`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.<CompleteSignInAsync>d__19[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[CustomUserAccount, Production.Hosted.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Authentication.WebAssembly.Msal.Models.MsalProviderOptions, Microsoft.Authentication.WebAssembly.Msal, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticatorViewCore`1.<ProcessLogInCallback>d__85[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticatorViewCore`1.<OnParametersSetAsync>d__83[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=6.0.14.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
(anonymous) @ blazor.webassembly.js:1
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
St @ blazor.webassembly.js:1
_mono_wasm_invoke_js_blazor @ dotnet.6.0.14.xn11rtcvo6.js:1
$func219 @ 00971dea:0x1a4c1
$func167 @ 00971dea:0xce8f
$func166 @ 00971dea:0xbd73
$func2815 @ 00971dea:0xabef3
$func1619 @ 00971dea:0x6fcb4
$func1623 @ 00971dea:0x70321
$mono_wasm_invoke_method @ 00971dea:0x969f
Module._mono_wasm_invoke_method @ dotnet.6.0.14.xn11rtcvo6.js:1
managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS:16
endInvokeJSFromDotNet @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
Promise.then (async)
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
St @ blazor.webassembly.js:1
_mono_wasm_invoke_js_blazor @ dotnet.6.0.14.xn11rtcvo6.js:1
$func219 @ 00971dea:0x1a4c1
$func167 @ 00971dea:0xce8f
$func166 @ 00971dea:0xbd73
$func2815 @ 00971dea:0xabef3
$func1619 @ 00971dea:0x6fcb4
$func1623 @ 00971dea:0x70321
$func3217 @ 00971dea:0xc4e85
$mono_background_exec @ 00971dea:0x9433e
Module._mono_background_exec @ dotnet.6.0.14.xn11rtcvo6.js:1
pump_message @ dotnet.6.0.14.xn11rtcvo6.js:1
setTimeout (async)
_schedule_background_exec @ dotnet.6.0.14.xn11rtcvo6.js:1
$func2392 @ 00971dea:0x942ef
$func3216 @ 00971dea:0xc4e15
$func219 @ 00971dea:0x1a529
$func167 @ 00971dea:0xce8f
$func166 @ 00971dea:0xbd73
$func2815 @ 00971dea:0xabef3
$func1619 @ 00971dea:0x6fcb4
$func1623 @ 00971dea:0x70321
$mono_wasm_invoke_method @ 00971dea:0x969f
Module._mono_wasm_invoke_method @ dotnet.6.0.14.xn11rtcvo6.js:1
managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS:16
endInvokeJSFromDotNet @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
Promise.then (async)
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
St @ blazor.webassembly.js:1
_mono_wasm_invoke_js_blazor @ dotnet.6.0.14.xn11rtcvo6.js:1
$func219 @ 00971dea:0x1a4c1
$func167 @ 00971dea:0xce8f
$func166 @ 00971dea:0xbd73
$func2815 @ 00971dea:0xabef3
$func1619 @ 00971dea:0x6fcb4
$func1623 @ 00971dea:0x70321
$mono_wasm_invoke_method @ 00971dea:0x969f
Module._mono_wasm_invoke_method @ dotnet.6.0.14.xn11rtcvo6.js:1
managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_EndInvokeJS:16
endInvokeJSFromDotNet @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
Promise.then (async)
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
St @ blazor.webassembly.js:1
_mono_wasm_invoke_js_blazor @ dotnet.6.0.14.xn11rtcvo6.js:1
$func219 @ 00971dea:0x1a4c1
$func167 @ 00971dea:0xce8f
$func166 @ 00971dea:0xbd73
$func2815 @ 00971dea:0xabef3
$func1619 @ 00971dea:0x6fcb4
$func1623 @ 00971dea:0x70321
$mono_wasm_invoke_method @ 00971dea:0x969f
Module._mono_wasm_invoke_method @ dotnet.6.0.14.xn11rtcvo6.js:1
managed_BINDINGS_SetTaskSourceResult @ managed_BINDINGS_SetTaskSourceResult:17
(anonymous) @ dotnet.6.0.14.xn11rtcvo6.js:1
Promise.then (async)
_wrap_js_thenable_as_task @ dotnet.6.0.14.xn11rtcvo6.js:1
_js_to_mono_obj @ dotnet.6.0.14.xn11rtcvo6.js:1
js_to_mono_obj @ dotnet.6.0.14.xn11rtcvo6.js:1
Fe._internal.getSatelliteAssemblies @ blazor.webassembly.js:1
St @ blazor.webassembly.js:1
_mono_wasm_invoke_js_blazor @ dotnet.6.0.14.xn11rtcvo6.js:1
$func219 @ 00971dea:0x1a4c1
$func167 @ 00971dea:0xce8f
$func166 @ 00971dea:0xbd73
$func2815 @ 00971dea:0xabef3
$func1619 @ 00971dea:0x6fcb4
$func1623 @ 00971dea:0x70321
$mono_wasm_invoke_method @ 00971dea:0x969f
Module._mono_wasm_invoke_method @ dotnet.6.0.14.xn11rtcvo6.js:1
_call_method_with_converted_args @ dotnet.6.0.14.xn11rtcvo6.js:1
call_method @ dotnet.6.0.14.xn11rtcvo6.js:1
(anonymous) @ dotnet.6.0.14.xn11rtcvo6.js:1
call_assembly_entry_point @ dotnet.6.0.14.xn11rtcvo6.js:1
callEntryPoint @ blazor.webassembly.js:1
At @ blazor.webassembly.js:1
await in At (async)
(anonymous) @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,396 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,569 questions
{count} votes