使用此代码:
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; }
}我要去System.AggregateException: One or more errors occurred在GoogleCredential.GetApplicationDefault()
我试图用C#生成一个自定义令牌,以便在DLL中使用。
PS:当我尝试使用GoogleCredential.FromFile时,我得到了一个InvalidOperationException: Error deserializing JSON credential data
环境
FirebaseAdmin: 1.9.1
Newtonsoft.Json: 12.0.3
.NET Framework: 4.8
发布于 2019-12-16 22:18:27
您可以查看InnerExceptions类的AggregateException属性,以找出问题的更具体原因。AggregateException对象在发生Task-related异常时抛出。
https://stackoverflow.com/questions/59364531
复制相似问题