- Home /
How do you authenticate GoogleSpeech using service agent credentials on Android?
Good Day,
I am having problems authenticating with a Unity C# project published on to Android where the resulting error on device is:
JsonSerializationException: Unable to find a constructor to use for type Google.Apis.Auth.OAuth2.JsonCredentialParameters. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'type', line 2, position 9.
I am using a service agent credential json that is being successfully used in multiple other apps and works in this app in editor on Windows and OSX. The issue only occurs when trying to set the credentials path.
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credentialsPath);
Being that it is Unity on Android I am already aware that accessing the streamingAssets folder is not accessible and am using the workaround of writing the file locally to the Application.persistantDataPath. With that I have verified that the file does exist and a valid path is being set.
Having worked on this issue for quite some time now I would mention that I have also tried to stop code stripping using the link.xml file but that does not appear to be working unless my syntax is incorrect.
Here is the full link.xml I am using currently
<type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Networking.DownloadHandlerBuffer" preserve="all" />
<namespace fullname="System.Security.Cryptography" preserve="all"/>
<namespace fullname="System.Security.Cryptography" preserve="all"/>
<!-- https://github.com/jilleJr/Newtonsoft.Json-for-Unity/issues/54 -->
<type fullname="System.Runtime.CompilerServices.NullableAttribute"/>
<type fullname="System.Runtime.CompilerServices.NullableContextAttribute"/>
<!-- https://github.com/jilleJr/Newtonsoft.Json-for-Unity/issues/8 -->
<!-- https://github.com/jilleJr/Newtonsoft.Json-for-Unity/issues/65 -->
<type fullname="Newtonsoft.Json.Converters.*Converter" preserve="all" />
<!-- No issue on these, though they are quite commonly used. -->
<type fullname="Newtonsoft.Json.Serialization.*NamingStrategy" preserve="all" />
<type fullname="Google.Apis.Auth.OAuth2.JsonCredentialParameters" preserve="all" />
<type fullname="Google.Apis.Auth.OAuth2.JsonCredentialParameters">
<method signature="System.Void.ctor()"/>
</type>
Your answer
Follow this Question
Related Questions
Google Play Games plugin for Unity Not Authenticating 9 Answers
Game Center login windows popups after hiding an app 0 Answers
Cannot authorize in GPGS 0 Answers