How to force "Google Sheets OAuth2 API" Credential go through http/https/socks proxy?

Hi,

my network can’t access to Google, so I configured a proxy using environment variables:

ALL_PROXY=<my http proxy>
HTTP_PROXY=<my http proxy>
HTTPS_PROXY=<my http proxy>

I created a Google Sheets OAuth2 API Credential follow this guide Credentials Google , after authorization at google website and redirect to /rest/oauth2-credential/callback got this error:

{"code":0,"message":"Unable to connect to oauth2.googleapis.com:443","hint":""}

I thinks there must be the “credentials HTTP request” don’t go through proxy:

  • don’t have “googleapis” log in my http proxy after unable to connect error
  • create a HTTP Request Node, set URL oauth2.googleapis.com,got request log in my http proxy and got response in HTTP Request Node

n8n version: 0.131.0

Hey @Juntao_Liu!

Welcome to the community! :sparkling_heart:

Port 443 is mentioned in the URL and that might be the reason you’re getting an error. Because of the way you have set up n8n, you have port 443 at the end of the URL. You will need to update your configurations.

Hey @harshil1712

do not understand how to update my configurations.

here is my n8n docker environments:

      - ALL_PROXY=http://<proxy-server-ip>:<port>
      - HTTP_PROXY=http://<proxy-server-ip>:<port>
      - HTTPS_PROXY=http://<proxy-server-ip>:<port>
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_DATABASE=<db-name>
      - DB_POSTGRESDB_HOST=<pg-host>
      - DB_POSTGRESDB_PORT=<pg-port>
      - DB_POSTGRESDB_USER=<pg-user>
      - DB_POSTGRESDB_SCHEMA=public
      - DB_POSTGRESDB_PASSWORD=<pg-password>
      - TZ=Asia/Shanghai
      - GENERIC_TIMEZONE=Asia/Shanghai
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=<username>
      - N8N_BASIC_AUTH_PASSWORD=<password>
      - N8N_HOST=<my-n8n-domain>
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_TUNNEL_URL=https://<my-n8n-domain>/

You are right. The exchange token request it’s not using the same library (the request library) to make the HTTP request. Hence, that request does not go through the proxy. Sadly, to change this, we would have to change the library or create our own.

What you can do it’s to use service account authentication instead.

:sob: really sad.

I tried service account credential to create google spreadsheet, but the created google sheet belong to service account. according to impersonate a user doc,it need Google workspace.

It looks like there is no viable solution for me.

:joy: I just found the solution to use Google Spreadsheet from here: Google Sheets API CONNECTION - #4 by RicardoE105

1 Use Google Service Account Credential
2 Create a Spreadsheet file
3 Share the Spreadsheet file with “Google Service Account” create at 1
4 Use this Spreadsheet file in n8n

1 Like