Google OAuth redirect issue
Trying to get oauth with Google to work. When I login it shows me the google accounts, I pick one and click continue but after logging in I end up back at the sign in page and there is no session. I followed everything here - https://labs.convex.dev/auth/setup. Any idea how to debug this?
15 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Can you share the authorized redirect url you used? Just the path, don't have to share the unique subdomain
https://<name>.convex.site/api/auth/callback/google
Can you share some code that isn't working the way you expect? Are you checking for the authenticated user client side or server side?
The only meaningful diff I see between this and the convex v1 template is the middleware uses
isAuthenticatedNextjs
instead of convexAuth.isAuthenticated
: https://github.com/get-convex/v1/blob/76e705b8dc78c3da702cceba999f5c1b2a35b663/apps/app/src/middleware.ts#L17-L23
Try thatTried that, but it didn't work. I just commented this out and it actually redirected correctly:
I tried logging from middleware and got this:
@Rishad B What version of Next.js are you using?
@ballingt 14.2.18
Is this a new project from a template or an existing project that you're adding auth to? Trying to determine how to reproduce.
I used
npm create convex@latest
to create the project and chose convex auth when promptedAlright, going to try that out
Probably going to switch to v1 or Clerk. That v1 template has some useful stuff. I'll keep my existing project folder in case you need help debugging.
The base create convex should be the most solid approach, so yeah I'm curious what might be the issue
That's why I went with it. I think I'll do base create convex with Clerk. Looks like I don't need to even use a custom oauth id client and secret with Clerk.