Auth0 LoginResult not able to load Newtonsoft.Json 10.0.0.0

3

I am facing a weird kind of situation while trying to achieve 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 the 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 the 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.

UPDATE

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() >

c#
auth0
asked on Stack Overflow Jul 20, 2018 by Md. Parwez Akhtar • edited Nov 7, 2019 by Bernard Vander Beken

1 Answer

1

Same problem here, with Auth0.OidcClient 2.2.0.0 and Newtonsoft.Json version 11.0.0.0.

I have no real solution for the problem, either. In the end I implemented a custom assembly resolve handler as a workaround.

To make sure that this does not affect the rest of the application, I am installing the handler only temporarily while the login window is open. I also make sure to only load the assembly named "Newtonsoft.Json". The handler looks for the Newtonsoft.Json assembly in the folder of the executing assembly.

answered on Stack Overflow May 10, 2019 by herzbube • edited May 10, 2019 by herzbube

User contributions licensed under CC BY-SA 3.0