使用没有文件的服务帐户凭据初始化 firebase 管理 - System.NotSupportedException - "Tag '27' not supported."

Initialize firebase management with Service Account Credential without files- System.NotSupportedException - "Tag '27' not supported."

 public static  class ServiceAccountManager
 {
 public static ServiceAccountKey Datakey { get; private set; }

 public static void CreateKey(string serviceAccountEmail)
    {            
        Datakey = Service.Projects.ServiceAccounts.Keys.Create(
            new CreateServiceAccountKeyRequest(),
            "projects/-/serviceAccounts/" + serviceAccountEmail)
            .Execute();
        Console.WriteLine("Created key: " + Datakey.Name);
    }
 .......
 }

使用私钥初始化

   private static void InitializeFirebaseManagement()
    {
       
        var servicecredential = new ServiceAccountCredential(new 
   ServiceAccountCredential.Initializer(CloudManager.ProjectId)
            .FromPrivateKey("-----BEGIN PRIVATE KEY----- 
   "+ServiceAccountManager.Datakey.PrivateKeyData+"-----END PRIVATE KEY-----")
        );
        var credential =GoogleCredential.FromServiceAccountCredential(servicecredential);
   if (CloudManager.Credential.IsCreateScopedRequired)
        {
            credential =CloudManager.Credential.CreateScoped(FirebaseManagementService.Scope.CloudPlatform);
        _firebaseManagementService = new FirebaseManagementService(
           new BaseClientService.Initializer()
           {
               
               HttpClientInitializer = credential,
               ApplicationName = CloudManager.ApplicationName

           });         
        }
    }

问题

无法从给定的 PKCS8 私钥中提取密钥(方法 FromPrivateKey())


输出

ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIsCiAgInByb2plY3RfaWQiOiAiZ2FtYW5ldC0yOSIsCiAgInByaXZhdGVfa2V5X2lkIjogImEyOGNjNzA4ZWFhNjFlZTBmNGQ0NWQ2NTRjZOXd2ZEM1VS9XNGlST3FSQXJmVFk3TzhcbjFQZEdhWVU3UHhJTjlsemhXTFJTR0xyWVp3MmtjeS95OG1TYVFUQUx1K3lzcjJVWVJGVjNJd1k1MmM1anVIQzBcbmNNTUxFSX...................GhfcHJvdmlkZXJfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9vYXV0aDIvdjEvY2VydHMiLAogICJjbGllbnRfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9yb2JvdC92MS9tZXRhZGF0YS94NTA5L2dhbWFuZXRjb20lNDBnYW1hbmV0LTI5LmlhbS5nc2VydmljZWFjY291bnQuY29tIgp9Cg==


异常

Java代码:

InputStream stream = new ByteArrayInputStream(key.decodePrivateKeyData());
GoogleCredential credential = GoogleCredential.fromStream(stream);

C#:

var buffer = Convert.FromBase64String(ServiceAccountManager.DataKey.PrivateKeyData);
Stream stream = new MemoryStream(buffer);
GoogleCredential credential = GoogleCredential.FromStream(stream);