With this code:
private async Task<string> DoCustomToken(string arg)
{
try
{
var uid = "some-uid";
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.GetApplicationDefault(),//GoogleCredential.FromFile("C:/config-production-firebase.json"),
ServiceAccountId = "<my-id>@<my-project-id>.iam.gserviceaccount.com",
}) ;
string customToken = await FirebaseAuth.DefaultInstance.CreateCustomTokenAsync(uid);
return customToken;
}
catch (Exception e) { return e.GetType().FullName + " - " + e.Message; }
}
I'm getting System.AggregateException: One or more errors occurred
at GoogleCredential.GetApplicationDefault()
I'm trying to generate a custom token with C# to be used in a DLL.
PS: When I try with GoogleCredential.FromFile
I get a InvalidOperationException: Error deserializing JSON credential data
Enviroment
FirebaseAdmin: 1.9.1
Newtonsoft.Json: 12.0.3
.NET Framework: 4.8
You can look at the InnerExceptions
property of the AggregateException
class to find more specific causes of your issue. AggregateException
objects are thrown when a Task
-related exception occurs.