Google spreadsheet service account auth error

When trying to auth with service account, i receive error

400 - {“error”:“invalid_grant”,“error_description”:“Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.”}

Light google-fu showed that it might be related to the local time issue, but the time is synced (its VDS in US tho). Any other suggestions based on your experience?

Hey @yavetal, unfortunately I was not able to reproduce this problem when trying to reproduce the problem just now and could use Google Sheets just fine with a Service Account:

But your assumption on this possibly being a time problem seems reasonable to me. When executing a test workflow like below, does it return the correct time for you?

Hi @yavetal

I have had no problem with Google Sheets so far. In my experience, I did have problems when I used Account Service as Authentication. Perhaps switching to OAuth2 as Authentication instead of Account Service could solve your issue. Pretty easy to set up, and you will have more flexibility to work on your Google Sheet later. I tried the Account Service before, and it went ugly when I needed more things transferred from N8N to Google Sheet for my project.

Setting up OAuth2 here: Google - n8n Documentation

Hope this help

1 Like

*wearing the necromancer’s hat

Something is really wrong with the spreadsheet creds. It worked fine before, but now i got the same error again.

And the current error is

{“message”:“400 - {"error":"invalid_grant","error_description":"Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim."}”,“name”:“Error”,“stack”:"Error: Request failed with status code 400\n at createError

And the time result is:

Kinda weird - should be 8:46 (US time), but it shows EU time instead (GMT, i guess?).

Yep, this time oAuth worked instantly. Looking good, thanks!