Auth0 Home Blog Docs

Auth0 LoginAsync complains about newtonsoft .json dll version 10.0.0.0

login
loginasync

#1

I am facing a weird kind of situation while trying acheiving LoginAsync using Auth0.OidcclientWpf SDK. I am using below code:

private async void PerformAuthenticationAsync()
{
    Auth0Client auth0Client = new Auth0Client(new Auth0ClientOptions()
    {
         Domain = "mydomain",
         ClientId = "clientid"
    });

     var extraParameters = new Dictionary<string, string>();
     extraParameters.Add("connection", "connectionParam");
     var result = await auth0Client.LoginAsync(extraParameters: extraParameters);
}

After performing authentication process. I am getting error:

Not able to load NewtonSoftJson.dll version - 10.0.0.0
and the source was Identitymodel.oidclient. Here after setting IdentityModelEventSource.ShowPII to True I can see in the trace that the token for which I am looking for is recieved but LoginResult is failed to decode the header.

I tried refering NewtonSoft.Json dll version 10.0.2 in my project. Now I am getting exception like:

Not able to load NewtonSoftJson.dll version 11.0.0.0
and this time Browser was not even launched to enter credentials.

I am confused which version of NewtonSoft.Json dll I should refer? I updated my IdentityModel.oidcclient to the latest version. Even after that IdentityModel.Oidcclient.LoginResult is complaining for NewtonSoft.Json version 10.0.0.0 unavailability.

I am not sure what is the real issue. Whether I have to refer both the versions(10 & 11) and how to do that? I would appreciate if someone can help.

below is the trace I am getting -

System.TypeInitializationException: The type initializer for ‘System.IdentityModel.Tokens.Jwt.JsonExtensions’ threw an exception. —> System.IO.FileLoadException: Could not load file or assembly ‘Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at System.IdentityModel.Tokens.Jwt.JsonExtensions…cctor() — End of inner exception stack trace — at System.IdentityModel.Tokens.Jwt.JsonExtensions.DeserializeJwtHeader(String jsonString) at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData) — End of inner exception stack trace — at System.IdentityModel.Tokens.Jwt.JwtSecurityToken.Decode(String[] tokenParts, String rawData) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ReadJwtToken(String token) at IdentityModel.OidcClient.IdentityTokenValidator.d__4.MoveNext() >


#3

:wave: @mohd.parwezakhtar were you able to solve your LoginAsync issue?


#5