Google oAuth issue on production
On local environment, google auth is working fine, however, on the production I am getting "An unknown error occurred while trying to log in with the OAuth provider.". No clue, no hint on console. I set redirect uri correctly. Does anyone know how to debug it?
wasp version: 0.13
13 Replies
Hi @IT Father. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To debug the Google OAuth issue you're experiencing in production, there are a few things you can check:
1. Environment Variables: Ensure that you've correctly set the
GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
in your .env.server
file for the production environment. These should match the credentials from your Google Cloud Console project Wasp Docs: Adding Environment Variables (https://wasp-lang.dev/docs/auth/social-auth/google#4-adding-environment-variables).
2. Redirect URIs: Double-check that you've added the correct production redirect URI in your Google Cloud Console project. It should be in the format <https://your-server-url.com/auth/google/callback
> Wasp Docs: Creating a Google OAuth App (https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app).
3. Server Logs: Check your server logs in your production environment (e.g., Fly.io dashboard if you're using Fly) for any error messages that might provide more information about the issue.
4. Client Configuration: Ensure that your client-side configuration for Google Auth is correct. Check your main.wasp
file to make sure the Google auth method is properly configured Wasp Docs: Default Behaviour (https://wasp-lang.dev/docs/auth/social-auth/google#default-behaviour).
5. Version Compatibility: Make sure you're using a compatible version of Wasp. If you're using an older version, consider updating to the latest version as some OAuth-related issues have been fixed in newer releases GitHub Issue: OAuth Patch (https://github.com/wasp-lang/wasp/issues/1724).
If you're still unable to resolve the issue, you might want to enable more verbose logging in your production environment to get more detailed error messages. Additionally, you could try to reproduce the error locally by setting up your local environment to mimic the production setup as closely as possible.
If the problem persists, you may want to reach out to the Wasp community on Discord for more specific help, as seen in some of the support threads provided in the knowledge sources.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @IT Father, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Check your server logs to see if there are any errors reported there π
There are no reported errors there
Wohooo @IT Father, you just became a Waspeteer level 1!
β
Solved: didn't set JWT token on prod, however, on local environment is not required.
Yes, we give you a dummy JWT secret in development while it's required in production: https://wasp-lang.dev/docs/advanced/deployment/manually#2-deploying-the-api-server-backend
Deploying Manually | Wasp
This document explains how to build and prepare your Wasp app for deployment.
I added this here https://github.com/wasp-lang/wasp/issues/2053#issuecomment-2441555673, so we can take into account that this is confusing.
GitHub
Make it clear in docs which env vars and how users need to set when...
We had a user struggling quite a bit with setting up env vars for their app while deploying it via wasp deploy fly deploy: https://discord.com/channels/686873244791210014/1241745021955473548/124174...
I've the same error message "An unknown error occurred while trying to log in with the OAuth provider.". It happens only in my railway env but works on my local env. JWT is configured on railway server.
Please find the server logs attached.
It says "Invalid state" that means that something is not set up properly - either the redirect URL or the OAuth provider in some way. Which OAuth provider are you using? Did you follow the docs on how to set it up?
Seems to be a domain issue, solved pointing directly to the railway url instead my custom domain for the backend. Thanks π
Your custom domain is for your client or for your server? There are two apps deployed, so keep that in mind π
I guess you pointed the redirect to your client URL, is that correct?
custom domain for both like:
- frontend: app.mycustomdomain.com
- backend: back.mycustomdomain.com
Instead of pointing on e.g. back.mycustomdomain.com, I've update to point on the railway default subdomain https://server-production-xxxxx.up.railway.app/
You could have pointed it to the custom domain - but you'd need to update all the env vars using the server URL