Ошибка шифрования с использованием файла JSON для аутентификации Google API API C # - PullRequest
0 голосов
/ 01 ноября 2019

моя проблема: я пытаюсь вызвать сервис облачной печати Google из ac # dll, но продолжаю сталкиваться с ошибкой шифрования:

System.Security.Cryptography.CryptographicException was unhandled
  HResult=-2146893819
  Message=Bad Data.

  Source=mscorlib
  StackTrace:
       at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
       at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)
       at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
       at Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer.FromPrivateKey(String privateKey) in C:\Users\cloudsharp\Documents\GitHub\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\ServiceAccountCredential.cs:line 91
       at GoogleCloudPrint.GoogleCloudPrintService.Authorize(String jsonCredentialPath) in C:\Source\ProVantage\GoogleCloudPrint\GoogleCloudPrintService.cs:line 304
       at GoogleCloudPrint.GoogleCloudPrintService..ctor(String jsonCredencialFilePath, String source) in C:\Source\ProVantage\GoogleCloudPrint\GoogleCloudPrintService.cs:line 46
       at addprinter.Program.Main(String[] args) in C:\Source\ProVantage\GoogleCloudPrint\addprinter\Program.cs:line 14
  InnerException: 

Поскольку я новичок в этом (Google API для облакапечать) Я начал с кода отсюда: https://github.com/io7/GoogleCloudPrint/

Сначала я попробовал с файлом .p12, но получил ошибки шифрования от mscorlib. затем я попытался использовать файл JSON (предпочтительный метод), и все еще получаю ошибки шифрованияЗатем я попробовал код здесь: Учетная запись службы Google не авторизована для API календаря , и проект не будет создан. так у кого-нибудь есть представление о том, чего мне не хватает?

Я использую Visual Studio 2015, работаю в Windows 7. использую файл, созданный из Google

...