Skip to content

Commit

Permalink
add profile type in google login callback request
Browse files Browse the repository at this point in the history
  • Loading branch information
asp345 committed Feb 4, 2025
1 parent 9b7f299 commit 7fa49bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion oauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ class GoogleLoginCallback(APIView):

def get(self, request, *args, **kwargs):
code = request.GET.get("code")
profile = request.GET.get("profile")

if not code:
return Response({"error": "Authorization code not provided"}, status=status.HTTP_400_BAD_REQUEST)
if not profile:
return Response({"error": "Profile not provided"}, status=status.HTTP_400_BAD_REQUEST)

token_url = "https://oauth2.googleapis.com/token"
payload = {
"code": code,
"client_id": settings.GOOGLE_OAUTH_CLIENT_ID,
"client_secret": settings.GOOGLE_OAUTH_CLIENT_SECRET,
"redirect_uri": settings.GOOGLE_OAUTH_CALLBACK_URL,
"redirect_uri": settings.GOOGLE_OAUTH_CALLBACK_URLS[profile],
"grant_type": "authorization_code",
}

Expand Down
2 changes: 1 addition & 1 deletion wemade_2024_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
# Google OAuth
GOOGLE_OAUTH_CLIENT_ID = os.getenv("GOOGLE_OAUTH_CLIENT_ID")
GOOGLE_OAUTH_CLIENT_SECRET = os.getenv("GOOGLE_OAUTH_CLIENT_SECRET")
GOOGLE_OAUTH_CALLBACK_URL = os.getenv("GOOGLE_OAUTH_CALLBACK_URL")
GOOGLE_OAUTH_CALLBACK_URLS = {"prod": os.getenv("GOOGLE_OAUTH_CALLBACK_URL_PROD"), "dev": os.getenv("GOOGLE_OAUTH_CALLBACK_URL_DEV"), "local": os.getenv("GOOGLE_OAUTH_CALLBACK_URL_LOCAL")}

SOCIALACCOUNT_PROVIDERS = {
"google": {
Expand Down

0 comments on commit 7fa49bf

Please sign in to comment.