Help me understand Google OAuth login flow please?

hey yall, I got authentication set up and working perfectly using next14, next-auth v5 and strapi v5 RC (and it took a while…)
Now I’m trying to implement OAuth using Google. I have my provider setup in next & next-auth, and I also got it set up in the strapi settings.
As I understand it, when a user clicks on the login with google button on my signin page, they should be redirected to strapi (http://localhost:1337/api/connect/google), which should then take them to google to log in. this all works fine. then, they’re supposed to be redirected back to strapi, which in turn will redirect them back to my frontend. That’s the part I can’t really understand. everything untill that point works fine. I think(?) that they should be redirected to next-auth’s api so it can handle auth, so I have strapi set to redirect to http://localhost:3000/api/auth/callback/google . but how does it work? strapi is supposed to receive an access_token from google, and then redirect to the frontend, at which point next (next-auth?) should send a request to strapi to log the user in, and if that’s successful then strapi will in theory return a user object and jwt, otherwise it will return null.

I cant seem to get any of this to work, I’m definitely missing something, but I cant underrstand what… can anyone help?

This topic has been created from a Discord post (1283694071138750484) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord