Error: "invalid_grant", Descripción: "JWT no válido: el token debe ser un token de corta duración y en un plazo razonable", Uri: ""
Estoy tratando de acceder al calendario de google con la ayuda de la cuenta de servicio de google pero recibí un error
Se produjo una excepción del tipo 'Google.Apis.Auth.OAuth2.Responses.TokenResponseException' en Google.Apis.dll pero no se manejó en el código de usuario
El error que estoy recibiendo:"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();