4 months ago
Summary
When using the Google Drive API with OAuth authentication in an n8n instance hosted on the Railway environment, the generated redirect URI defaults to the Railway-provided domain (e.g., *.railway.app
) instead of a configured custom domain (e.g., n8n.callteksupport.com
). This causes a mismatch between the redirect URI and the authorized redirect URI configured in the Google Cloud Console, resulting in a 400 invalid_request
error during authentication.
Steps to Reproduce
Deploy an n8n cluster on Railway using the provided template.
Configure a custom domain (e.g.,
n8n.callteksupport.com
) via DNS.Add a
CNAME
record pointing the custom domain to the Railway-provided domain (e.g.,primary-production-2f4f.up.railway.app
).
Add the custom domain to the WEBHOOK_URL environment variable in n8n.
Configure the Google Drive API and set the authorized redirect URI in the Google Cloud Console to match the custom domain:
Copy code
https://n8n.callteksupport.com/rest/oauth2-credential/callback
Attempt to authenticate the Google Drive API in n8n.
Expected Behavior
n8n should generate the redirect URI using the configured custom domain (https://n8n.callteksupport.com/rest/oauth2-credential/callback
), allowing successful OAuth authentication.
Actual Behavior
The generated redirect URI defaults to the Railway-provided domain (https://primary-production-2f4f.up.railway.app/rest/oauth2-credential/callback
), resulting in a mismatch and a 400 invalid_request
error from Google.
Environment
n8n Version: (e.g., 1.x.x)
Deployment Environment: Railway
Custom Domain:
n8n.callteksupport.com
Google Cloud Configuration:
Authorized redirect URI:
https://n8n.callteksupport.com/rest/oauth2-credential/callback
Enabled Scopes: Google Drive API (
https://www.googleapis.com/auth/drive
)
Logs & Error Details
Error Message:
Copy code
Error 400: invalid_request Request details: redirect_uri=primary-production-2f4f.up.railway.app/rest/oauth2-credential/callback
Railway Logs: (Provide relevant snippets showing environment variables and URI generation behavior, if available)
Workarounds Attempted
Configured
WEBHOOK_URL
environment variable tohttps://n8n.callteksupport.com
.Updated Google Cloud Console to include both Railway domain and custom domain in authorized redirect URIs.
Verified DNS configuration (CNAME for custom domain points to Railway-generated domain).
Despite these steps, n8n continues to generate the redirect URI using the Railway-provided domain, ignoring the WEBHOOK_URL
configuration.
Proposed Solution
Ensure n8n respects the
WEBHOOK_URL
environment variable when generating redirect URIs for OAuth authentication.Allow explicit configuration of the redirect URI through an environment variable or other settings.
Severity
Impact: Blocks integration with Google Drive API.
Priority: High for users relying on OAuth-based integrations with custom domains in Railway deployments.
Additional Context
The issue is specific to OAuth-based integrations in n8n hosted on Railway. Other webhook functionalities may not be affected if the WEBHOOK_URL
is properly respected.
10 Replies
4 months ago
Hello,
Due to the AI generated message it is unclear to me if you ended up coming to a solution for yourself?
brody
Hello,Due to the AI generated message it is unclear to me if you ended up coming to a solution for yourself?
4 months ago
No, I've made a series of changes to validate my configuration, including testing my Google credentials to ensure I was configured correctly (it is). It's hard for me to believe this hasn't happened before.
The n8n instance seems to be running ok with the custom domain name. But getting the Google Drive API is just not happening.
4 months ago
I've made changes that have worked for other users in the past, please Deploy my changes and then test again.
brody
I've made changes that have worked for other users in the past, please Deploy my changes and then test again.
4 months ago
Brody, did I miss where you provided me your changes?
4 months ago
There is a little model that shows two changes at the top of your project canvas, you can review them and Deploy the changes -
Attachments
brody
There is a little model that shows two changes at the top of your project canvas, you can review them and Deploy the changes -
4 months ago
sorry to be dense, but all I see here is an image. No details of the changes
4 months ago
You can click the Details button to show details, and then once you are okay with the changes I made, you click the Deploy button.
Are you able to see the image I attached in my last message?
4 months ago
Brody, while they help to correct the internal mapping issue. It didn't resolve Google Drive API with OAuth authentication problem. Turns out I think the issue was with the Google Policy Layer. I believe that my use of the n8n as a subdomain name was the issue. Google seems to be looking for possible branding issues with brand names like, you can't have a google or gdrive subdomain without it being flagged as a policy issue. I changed the subdomain to app. and it fixed the issue with authorizing the Google Drive Node in n8n.
Status changed to Solved brody • 4 months ago