Rishad B
Rishad B2mo ago

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
Convex Bot
Convex Bot2mo ago
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!
erquhart
erquhart2mo ago
Can you share the authorized redirect url you used? Just the path, don't have to share the unique subdomain
Rishad B
Rishad BOP2mo ago
https://<name>.convex.site/api/auth/callback/google
erquhart
erquhart2mo ago
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?
erquhart
erquhart2mo ago
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 that
Rishad B
Rishad BOP2mo ago
Tried that, but it didn't work. I just commented this out and it actually redirected correctly:
export default convexAuthNextjsMiddleware((request) => {
// if (isSignInPage(request) && isAuthenticatedNextjs()) {
// return nextjsMiddlewareRedirect(request, "/releases");
// }
// if (isProtectedRoute(request) && !isAuthenticatedNextjs()) {
// return nextjsMiddlewareRedirect(request, "/signin");
// }
});
export default convexAuthNextjsMiddleware((request) => {
// if (isSignInPage(request) && isAuthenticatedNextjs()) {
// return nextjsMiddlewareRedirect(request, "/releases");
// }
// if (isProtectedRoute(request) && !isAuthenticatedNextjs()) {
// return nextjsMiddlewareRedirect(request, "/signin");
// }
});
I tried logging from middleware and got this:
isAuthenticatedNextjs false
convexAuth false
isAuthenticatedNextjs false
convexAuth false
ballingt
ballingt2mo ago
@Rishad B What version of Next.js are you using?
Rishad B
Rishad BOP2mo ago
@ballingt 14.2.18
erquhart
erquhart2mo ago
Is this a new project from a template or an existing project that you're adding auth to? Trying to determine how to reproduce.
Rishad B
Rishad BOP2mo ago
I used npm create convex@latest to create the project and chose convex auth when prompted
erquhart
erquhart2mo ago
Alright, going to try that out
Rishad B
Rishad BOP2mo ago
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.
erquhart
erquhart2mo ago
The base create convex should be the most solid approach, so yeah I'm curious what might be the issue
Rishad B
Rishad BOP2mo ago
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.

Did you find this page helpful?