Oauth not working for google or github.
Both Google and GitHub sign-ins are showing an error saying the redirect isn't working. I've set up the correct URL in the backend. Is there something I need to add to my app?
11 Replies
Hi @khb. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, there are a few things you should check to ensure OAuth is working correctly for Google and GitHub in your Wasp app:
1. Make sure you've defined the
WASP_SERVER_URL
environment variable. This is a new requirement in Wasp 0.13.0 and is used to generate the redirect URL for OAuth providers. In development, it defaults to <http://localhost:3001
,> but you need to set it explicitly for production Migration guide (https://wasp-lang.dev/docs/migrate-from-0-12-to-0-13#migrate-your-oauth-setup-part-1).
2. Update the redirect URLs in your Google and GitHub OAuth app settings:
- For Google: <http://localhost:3001/auth/google/callback
> (development) or <https://your-server-url.com/auth/google/callback
> (production) Google OAuth setup (https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app)
- For GitHub: <http://localhost:3001/auth/github/callback
> (development) or <https://your-server-url.com/auth/github/callback
> (production) GitHub OAuth setup (https://wasp-lang.dev/docs/auth/social-auth/github#3-creating-a-github-oauth-app)
3. Ensure you've added the correct environment variables to your .env.server
file:
Google env vars (https://wasp-lang.dev/docs/auth/social-auth/google#4-adding-environment-variables), GitHub env vars (https://wasp-lang.dev/docs/auth/social-auth/github#4-adding-environment-variables)
4. Check that your main.wasp
file includes the correct configuration for Google and GitHub auth methods:
Auth configuration (https://wasp-lang.dev/docs/auth/overview#auth-fields)
5. If you're using custom userSignupFields
or configFn
, make sure they're up to date with the latest Wasp version. There have been some changes in how these are defined Migration guide (https://wasp-lang.dev/docs/migrate-from-0-12-to-0-13#migrate-your-oauth-setup-part-2).
If you've checked all these points and are still experiencing issues, you may need to review your server logs for more detailed error messages or consult the Wasp community for further assistance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @khb, 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?Update the redirect URLs in your Google and GitHub OAuth app settings:
For Google: http://localhost:3001/auth/google/callback (development) or https://your-server-url.com/auth/google/callback (production) Google OAuth setup (https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app)
For GitHub: http://localhost:3001/auth/github/callback (development) or https://your-server-url.com/auth/github/callback (production) GitHub OAuth setup (https://wasp-lang.dev/docs/auth/social-auth/github#3-creating-a-github-oauth-app) can you tell me more about this, i have a website siteengineer.com.au, but im sure sure how to tell the server url on that and im not sure where i can find that or if i have to set somthing up on the back end like dns
GitHub | Wasp
Wasp supports Github Authentication out of the box.
Google | Wasp
Wasp supports Google Authentication out of the box.
@kapa.ai
Let me check the knowledge base for you again. One moment! :books:
Sorry @khb, 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?
The oauth redirects go through the backend. And I'm guessing that domain is your frontend domain.
As the authorized redirect domain, set the one you use as the backend domain. It seems like it's the fly generated one that you see in your error message
sorry for my igonroace but, so should i set my WASP_SERVER_URL to my website url https://siteengineer.com.au/
Site Engineer
Site Engineer is a platform for designing and calculating nozzle designs for industrial applications.
Nop.
WASP_SERVER_URL
correctly points to https://my-site-engineer-server.fly.dev
which is where your backend is running.
In authorized redirect URLs, where you are setting up google oauth, instead of using siteengineer.com.au
, use my-site-engineer-server.fly.dev
okay, sweet. i did that and it works. Thank you.
Nice, I'm glad I was able to help:)
@Joaquim thank you for jumping it 🙂