How can we use nextauth in google idx

I’ve been trying to implement NextAuth with Google Identity Platform (IDX) for a long time but haven’t been successful. Initially, I tried using the GitHub provider, but I kept getting an error saying that the redirect URL is not authorized.

I asked ChatGPT for help, and it suggested that the issue was due to the temporary URLs used by IDX. I faced the same problem when trying to implement it in Replit.

Then, I decided to use the Google provider, but I encountered the same authorization issue with the redirect URL.

Has anyone successfully set up NextAuth with Google IDX? How did you handle the redirect URL authorization issue? Any help would be greatly appreciated!

1 Like

I’d recommend testing this locally instead. The issue is that NextAuth in IDX struggles with GitHub/Google providers because:

  1. The workspace URL is temporary and private
  2. OAuth redirects to localhost won’t work since you’re accessing through a forwarded proxy URL

This is a common OAuth configuration challenge in containerized development environments.

Actually my pc is not that strong to work with heavy libarary like next that’s why I use Google idx and also I move from one place to another regular and in between I try to do the work so is there any option that I can do in idx only

Oh hey, I totally get it - I was facing the same problem few years back and did most in GH codespaces.

So I just tested this out myself and got it working! I put together a quick example repo here: GitHub - securethinker295/idx-next-auth: A simple next project which works in IDX with next auth

The trick is super simple:

  1. Make your IDX workspace public (seriously, this is important)
  2. Grab the preview URL that IDX gives you and use that same URL in both your GitHub OAuth settings and your .env file(Copy this from the URL bar after the initial site opens. Don’t copy it from the IDX tab in editor)

Check out the README - it’s pretty straightforward. Just hit “import” in IDX, paste that repo URL, and you’re like 80% there already. Let me know if you get stuck!

1 Like

Okay thanks I Will try my best

1 Like

sorry phantom for disturbing you again but since idx had updated to firebase studio and now i am unable to find a button to make workspace public :sweat_smile:

Check out the 10:30 minute mark here :slight_smile:

We will make this more discoverable in future UI updates.

2 Likes

Oh wow, thank you so much! That really blew my mind :exploding_head:—I appreciate it a lot! Also, how did you get that Google logo in your username? :eyes: I need it in mine too! (Just kidding… or am I? :smirking_face:)

Seriously though, you’re awesome. Thanks again! :raising_hands::sparkles:

1 Like


Hey No worries, Just start your server click on the firebase icon on the sidebar ans under the BACKEND PORTS option just click on the lock icon it will make the URL public.

2 Likes

thank you very much phantom

Hey Phantom, I’m really sorry, truly sorry :folded_hands:, but I’m struggling with this authentication issue. I know it might sound selfish to ask, but could you please create a video solution for me? Please, please, please :folded_hands::sparkles: