Recurring Google Services Authentication Issue in Self-Hosted n8n

Google Drive, Gmail and many other Google Products keep disconnecting in my n8n instance. Clicking on “Sign in with Credentials” reconnects immediately, but it only stays connected for a couple of days before requiring me to reestablish the connection again.

I’m hosting n8n on a GCP instance but didn’t have these connection problems before. The OAuth tokens seem to be expiring frequently, requiring manual reconnection every few days.

Information on your n8n setup

  • n8n version: 1.81.4
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): GCP docker
  • Operating system: Windows10
1 Like

There have been a lot of changes to google auth recently, and n8n has made some changes to address these, are you on latest version?

But it is also just a common bug for oauth to fail, due to internally not correctly refreshing the oauth token.

The annoying but recommended workaround is to handle the oauth flow manually, saving the auth and refresh token, and making a new refresh grant before making major requests. The refresh tokens usually live 30-90 days, where a auth token will only like 1-7.

Could you also show your cred setup (blurring/removing half of keys/PIIs)?

Thanks for the response. I am on version 1.81.4

Even 30-90days wouldnt be great is there any reason why this occurs with all of the google products?

I mean this basically destroys the entire use case of these automations if I have to reconnect these modules.
Google Sheets Oauth with a different account seems to work. I don’t see a pattern here.

What do you mean seems to work? One doesnt one does?

And you can set the refresh and auth tokens into a sheet or db, and fetch and use them within the workflow, its an added step, but it doesn’t remove from the ability to create and use nodes on n8n. Although you would have to use manual http requests instead of the in built node.

Don’t really get where you are going with this I mean I need the Credentials to work indefinitely or at least longer than a week otherwise the automations are no automations

And I was talking about Google Sheets API which seems to now be connected for 3 weeks no problems.

But the Google Sheets API might be the only one which is getting called every day while the others arent called - thats the only major difference I could figure out.

@ThinkBot persists even with the latest version. Google Sheets doesnt seem to be a problem (at least I don’t realize) but GMAIL desynches like every 4 days

Hi, You can use a service account instead. Regards
J.

1 Like

Not sure I understand correctly. How can I set this up and will this prevent the tokens from every needing to refresh?

Greetings

Hi,

Here you can find more info:

Reg,
J.

3 Likes

@jcuypers
Will this lead to a timeless connection or is there always a max time? Cause currently it disconnects after a couple of days.

Well, it depends on JWT tokens being renewed but apart that it should but without limit.

Reg,

Please accept my answer as solution.

@jcuypers I simply solved it by using the access token once a day with an automation that just reads the same sheet file. But thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.