Ошибка: «invalid_grant», Описание: «Invalid JWT: токен должен быть токеном с коротким сроком действия и в разумные сроки», Uri: «»
Я пытаюсь получить доступ к Google-календарю с помощью учетной записи службы Google, но я получил ошибку
Исключение типа «Google.Apis.Auth.OAuth2.Responses.TokenResponseException» возникло в Google.Apis.dll, но не было обработано в коде пользователя
Ошибка, которую я получаю:"invalid_grant", Description:"Invalid JWT: Token must be a short-lived token and in a reasonable timeframe", Uri:""
string credPath = "key path";
String serviceAccountEmail = [email protected]";
var certificate = new X509Certificate2(credPath, "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { CalendarService.Scope.CalendarReadonly,
CalendarService.Scope.Calendar}
}.FromCertificate(certificate));
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "HRTool",
});
var events = service.Events.List("my calaender id").Execute();