Frequent Reauthentication Required with YouTube API and google sheet API

Hi everyone,

I’m currently using n8n to integrate with the YouTube API, but I keep encountering an issue where I have to reauthenticate frequently. After a short period of time, the authentication token seems to expire, and I have to go through the OAuth2 process again.

Here’s what I’ve tried so far:

  1. I’ve configured the OAuth2 credentials in n8n and made sure they are saved correctly.
  2. From what I understand, the refresh token should be used automatically by n8n to get a new access token when the previous one expires, but this doesn’t seem to be happening.
  3. I’m using the latest version of n8n, and the YouTube API permissions seem correctly set up.

My question is:

  • Why does this reauthentication keep happening?
  • How can I ensure that the refresh token is used to automatically renew the access token without needing manual intervention?

I’d appreciate any insights or advice on how to solve this. Thanks in advance!

Debug info

core

  • n8nVersion: 1.60.1
  • platform: docker (self-hosted)
  • nodeJsVersion: 20.17.0
  • database: postgres
  • executionMode: regular
  • concurrency: -1
  • license: community
  • consumerId: unknown

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

Generated at: 2024-09-30T07:17:41.282Z

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Can you check the status of your Google App? See the Google OAuth2 documentation:

Google Cloud app becoming unauthorized#

For Google Cloud apps with Publishing status set to Testing and User type set to External, consent and tokens expire after seven days. Refer to Google Cloud Platform Console Help | Setting up your OAuth consent screen for more information. To resolve this, reconnect the app in the n8n credentials modal.

Thank you. How can I avoid this and have a token that doesn’t expire?

You need to set the Google app to ‘in production’. You can find more information about this in their documentation.

1 Like