Выполните аутентификацию в Google ShoppingContentService в .Net Standard 2.0 - PullRequest
0 голосов
/ 11 апреля 2019

Попытка аутентификации в Google ServiceAccountCredential, и я получаю ошибку. Невозможно привести объект типа 'RSACng' к типу 'System.Security.Cryptography.RSACryptoServiceProvider'.

Я пытался использовать GoogleCredential, чтобы сделатьthis

 GoogleCredential credential = GoogleCredential.FromJson(json).CreateScoped(new[] { ShoppingContentService.Scope.Content });

service = new ShoppingContentService(new BaseClientService.Initializer()
{
     HttpClientInitializer = (IConfigurableHttpClientInitializer)credential
});

И я попытался с помощью

 ServiceAccountCredential credential = new ServiceAccountCredential(
            new ServiceAccountCredential.Initializer(serviceAccountEmail)
            {
                Scopes = new[] { ShoppingContentService.Scope.Content }
            }.FromCertificate(certificate);

И то и другое выдает ошибку. Невозможно привести объект типа 'RSACng' к типу 'System.Security.Cryptography.RSACryptoServiceProvider'.Как обойти Google, по-видимому, только принимая RSACryptoServiceProvider и мой код, автоматически устанавливающий закрытые ключи RSACng для сертификата?

...