3

I am setting up a technical blog with the following infrastructure:

Client <---domain.tld:80---> Nginx Reverse Proxy <---localhost:8001---> Docker container with Django web app

I am using Gunicorn as WSGI web server within my container.

The problem I am facing is that when I want to include Google authentication for my comment section and call my corresponding URI for authentication (which is http://domain.tld/auth/login/google-oauth2/), I get the following error from google:

The redirect URI in the request, http://localhost:8001/auth/complete/google-oauth2/, does not match the ones authorized for the OAuth client.

So the main problem is that google thinks I want the redirect host to be localhost, because my app is deployed on localhost (and only served via my reverse proxy to the internet), but of course I need it to be domain.tld instead.

I didn't found an option were I can explicitly tell google were the traffic should be redirected to, I only can authorize URIs.

Of course I tried to allow localhost redirect access, but obviously this doesn't help because google redirects to the localhost URI.

My code is mainly based on this blog post and this stackoverflow question.

As this is mainly a link call to a URL from my server, I think my code shouldn't be that useful at all.

I am thankful for any helpful feedback!

Dominic
  • 31
  • 2
  • The reason "google thinks I want the redirect host to be localhost," is because somewhere in your app, that's what you are telling Google. You'll need ti dig into the oauth library that yu are using to see how to tell it what your redirect url is. – pinoyyid Mar 27 '19 at 23:42
  • Did you figure this out? – danish_wani Apr 05 '22 at 11:17

1 Answers1

0

You can use serveo (or a similar service - ngrok, etc) to expose your local server and have google or other oauth provider callback through it.

You can also ignore this problem and login through /admin in local environment.

Kyryl Havrylenko
  • 674
  • 4
  • 11