Skip to content

Commit

Permalink
Hack for wrong hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoacierno committed Jul 29, 2023
1 parent cc3b8b8 commit 95cd757
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions backend/google_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any
from django.conf import settings
from django.contrib import admin
from django.db.models.query import QuerySet
from django.http.request import HttpRequest
Expand Down Expand Up @@ -57,9 +58,18 @@ def build_google_flow(self, request, obj, *, state=None):
scopes=GOOGLE_CLOUD_SCOPES,
state=state,
)
flow.redirect_uri = request.build_absolute_uri(
reverse("admin:google-api-oauth-callback", args=(obj.id,))
)
if settings.DEBUG:
flow.redirect_uri = request.build_absolute_uri(
reverse("admin:google-api-oauth-callback", args=(obj.id,))
)
else:
# TODO: this is an hack because we have a middleware that forces
# the host to be "pycon.it"
# once we remove the middleware we can remove this if
flow.redirect_uri = "https://admin.pycon.it" + (
reverse("admin:google-api-oauth-callback", args=(obj.id,))
)

return flow

def auth_callback(self, request, object_id):
Expand Down

0 comments on commit 95cd757

Please sign in to comment.