Get “FirebaseException: Cannot parse null string” when using FirebaseAppCheck.GetAppCheckTokenAsync with secondary FirebaseApp instance

  Kiến thức lập trình

I’m using AppCheck version 12.1.0 for my Unity(version 2022.3.20f1)’s game with secondary firebase app instance follow this instruction https://firebase.google.com/docs/projects/multiprojects#use_multiple_projects_in_your_application. I also done setup app check in both my main and secondary firebase project via firebase console. Then, when I call appCheck.GetAppCheckTokenAsync for secondary firebase app, I get an exception One or more errors occurred. (Provider returned an Exception: System.AggregateException: One or more errors occurred. (Cannot parse null string) ---> Firebase.FirebaseException: Cannot parse null string. Follow is the simple code flow to demonstrate the firebase code flow in my project and full stacked trace for exception:

FirebaseAppCheck.SetAppCheckProviderFactory(PlayIntegrityProviderFactory.Instance);
FirebaseApp.Create(_appOptionsStagingAndroid, "SecondaryApp");
var instance = Firebase.FirebaseApp.GetInstance("SecondaryApp");
var appCheck = FirebaseAppCheck.GetInstance(instance);
var appCheckToken = await appCheck.GetAppCheckTokenAsync(false);
One or more errors occurred. (Provider returned an Exception: System.AggregateException: One or more errors occurred. (Cannot parse null string) ---> Firebase.FirebaseException: Cannot parse null string
08-02 15:23:05.567 31914 31984 E Unity   :    --- End of inner exception stack trace ---
08-02 15:23:05.567 31914 31984 E Unity   : ---> (Inner Exception #0) Firebase.FirebaseException: Cannot parse null string<---
08-02 15:23:05.567 31914 31984 E Unity   : )
08-02 15:23:05.567 31914 31984 E Unity   :   at Firebase.AppCheck.FirebaseAppCheck+<>c.<GetAppCheckTokenAsync>b__13_0 (System.Threading.Tasks.Task`1[TResult] task) [0x00000] in <00000000000000000000000000000000>:0
08-02 15:23:05.567 31914 31984 E Unity   :   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () [0x00000] in <00000000000000000000000000000000>:0
08-02 15:23:05.567 31914 31984 E Unity   :   at System.Threading.Tasks.Task.Execute () [0x00000] in <00000000000000000000000000000000>:0
08-02 15:23:05.567 31914 31984 E Unity   :   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSync

I have tried checking null and try catch for each step but the error always happened at appCheck.GetAppCheckTokenAsync. When I tried using FirebaseAppCheck.DefaultInstance instead of FirebaseAppCheck.GetInstance(secondaryFirebaseApp), I successfully got the app check token. Did I do anything wrong or any step that I’m missing? And what is the exactly exception ” Cannot parse null string” meaning? I just curious because I log all apiKey, appId and projectId for secondary firebase app instance and none of that is null or empty.

New contributor

Basa102 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT