Google auth not working in production
I had set up google auth in dev and it worked without problems but it cause a lot of problems in production.
I am using the opensaas template. The documentation doesn't really mention how to get it working for production.
I have set up the oauth app and credentials in google and passed the client id and secret to fly through cli.
It doesn't throw an error but also doesn't log the user in when atempting to log in with google.
I feel like there is no accurate documentation for this. The open saas documentation mentions that only the google auth part has to be uncommented and a google oauth app has to be created but that doesn't go further than dev stage.
Even when passing the client id and secret to fly it doesn't seem to work. Is there any better documentation about this somewhere?
36 Replies
Hi @fred-123. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I understand your frustration and I'm here to help. Based on the knowledge sources provided, it seems like you've done most of the steps correctly. However, there are a few things you might want to check:
1. Google OAuth App Configuration: Make sure that you have added the correct redirect URIs in your Google OAuth App. For production, you should add your production server URL to the list of authorized redirect URIs. For example:
<https://your-server-url.com/auth/google/callback
.> You can check this in your Google Cloud Console here (https://console.cloud.google.com/home/dashboard).
2. Environment Variables: Ensure that you have added the Google Client ID and Client Secret to your .env.server
file. This file should be at the root of your project and should look something like this:
You can find more details about this in the Wasp documentation (https://wasp-lang.dev/docs/auth/social-auth/google#4-adding-environment-variables).
3. User Signup Fields: Make sure that your userSignupFields
and configFn
match the latest implementation. An outdated implementation might cause issues. Here's an example of how it should look:
You can find more details about this in the Wasp Discord community (https://discord.com/channels/686873244791210014/1222916615151161374).
If you've checked all of these and it's still not working, I would recommend reaching out to the Wasp community on Discord for further assistance. They are very helpful and might be able to provide more specific guidance based on your situation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @fred-123, 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?Open SaaS is a template for the Wasp framework, have you checked the revelant docs for Google auth here: https://wasp-lang.dev/docs/auth/social-auth/google
Google | Wasp
Wasp supports Google Authentication out of the box.
@miho I have over and over again.
I noticed something odd. My version of opensaas seems to be quite different from the one on github.
I got opensaas a month or two ago and started with wasp 0.13. I have since migrated to wasp 0.14.
For example here is my google auth code from main.wasp:
// Uncomment to enable Google Auth (check https://wasp-lang.dev/docs/auth/social-auth/google for setup instructions):
google: { // Guide for setting up Auth via Google
userSignupFields: import { getGoogleUserFields } from "@src/server/auth/setUsername.js",
configFn: import { getGoogleAuthConfig } from "@src/server/auth/setUsername.js",
but it looks like this on gituhub:
// Uncomment to enable Google Auth (check https://wasp-lang.dev/docs/auth/social-auth/google for setup instructions):
// google: { // Guide for setting up Auth via Google
// userSignupFields: import { getGoogleUserFields } from "@src/auth/userSignupFields",
// configFn: import { getGoogleAuthConfig } from "@src/auth/userSignupFields",
// },
Google | Wasp
Wasp supports Google Authentication out of the box.
I think we updated the template a bit, yep π
1. What do you see in your browser console? Share a screenshot
2. What do you see in your app on the login page? Share a screenshot
3. What do you see in the server terminal? Share a screenshot if there are some errors
Does that mean with my version of open saas the documentation won't work for me anymore and i have to rebuild it with the new template?
@Vinny (@Wasp) one for you
It shows nothing but the website header after trying to log in with google auth and takes me here:
https://my-app.com/auth/google/callback?state=620nn8OP_gpjx0mWm-mxm9jd5ViO7Am9G-lx-adg0T4&code=4%2F0AcvDMrCzrKaxNjuxivncb518RqUeFVS4JbT1qTG70Khl-6LDcffmBFgAWxRd6A4A19m2JA&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=0&hd=myapp.com&prompt=consent
here the server logs:
Ok, I think I know what's up
The docs say
Once you know on which URL(s) your API server will be deployed, also add those URL(s). For example: https://your-server-url.com/auth/google/callbackThe key detail is - server URL, and not the client URL Which Wasp version are you using?
I tried that to and i get another error. It then says something like uri mismatch. Let me try and find the exact error
i upgrade to 0.14 yesterday
Did you deploy the 0.14 version?
That's good, I suspect you have an older Wasp version deployed - the URI mismatch confirms that
I had the site deployed using wasp 0.13 initially and then redeployed after doing the update to 0.14. Did i miss something else i have to do?
How can i confirm the wasp version of the deployed app?
Shouldn't it be also updated to wasp 0.14 when i redeploy or is that not how it works?
What do you suggest i do now?
Take the deployed website down and run wasp deploy fly launch again?
Rebuild the entire site with the new template?
I have been trying a bunch of stuff over the past 3 days and just can't get it to work. I have read and tried everything in the documentation but there just seems to be a lot of differences between the opensaas template i am using and the current one.
Is there any way to get the templates to match again without having to start over again? How do others solve that problem that use the opensaas template?
Which commands did you run to deploy the new version of the app? Did you follow the migration guide? Did you get any errors that might suggest the deployment didn't go through?
@Vinny (@Wasp) @matija maybe you can give some ideas here
I did but i skipped the steps such as "Replace the getUsername helper with user.identities.username.id", "6. Migrate Prisma preview features config to the schema.prisma file", "Replace the getEmail helper with user.identities.email.id", "Replace accessing providerData with user.identities.<provider>.<value>", "Use getFirstProviderUserId directly on the user object", "Replace findUserIdentity with checks on user.identities.<provider>" as i couldn't find any occurences of these in my codebase.
I ran: REACT_APP_STRIPE_CUSTOMER_PORTAL=https://billing.stripe.com/p/login/test_somethingmadeup wasp deploy fly deploy
I tried wasp clean and wasp build now and build fails.
I get type mismatch errors:
can you remove the radius property from the barchart.tsx file and try again
?