JsonSerializationException: Unable to find a constructor for Auth0.AuthenticationApi.Models.DeviceCodeResponse


We are developing a VR application using Unity, and for that I set up Auth0 inside using the guidelines here:

It is already working in Unity Editor, but on the device (Android) it is throwing this exception:

2022.05.31 10:48:16.705 5710 5760 Error Unity JsonSerializationException: Unable to find a constructor to use for type Auth0.AuthenticationApi.Models.DeviceCodeResponse. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'device_code', line 1, position 15.
2022.05.31 10:48:16.705 5710 5760 Error Unity   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id, System.Boolean& createdFromNonDefaultCreator) [0x00000] in <00000000000000000000000000000000>:0
2022.05.31 10:48:16.705 5710 5760 Error Unity   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract contai

The problem is coming from this line of code on Unity side:

AuthManager.Instance.Auth0.ExchangeDeviceCodeAsync(clientId, deviceCodeResp.DeviceCode, deviceCodeResp.Interval);

Since the problem is coming from a class in the DLL, I can’t modify it to resolve the issue. Did anybody encounter something similar and can help?

Thanks a lot!

Hey there!

What I suggest here is to raise a GitHub issue in the repo so we can get direct help from one of the maintainers. Thank you! Once you have a link to it you can share it here so we can ping them.

1 Like

Hello was this issue resolved?
as I’m also getting the same error