Spaces:
Runtime error
Runtime error
Update service/auth_service.py
Browse files- service/auth_service.py +10 -10
service/auth_service.py
CHANGED
|
@@ -54,29 +54,29 @@ class AuthService:
|
|
| 54 |
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e))
|
| 55 |
|
| 56 |
@staticmethod
|
| 57 |
-
def get_google_oauth_url(
|
| 58 |
try:
|
| 59 |
-
#
|
| 60 |
-
# to the callback URL that Supabase will use.
|
| 61 |
base_callback = "https://hammad712-digitalbillboard.hf.space/auth/callback"
|
| 62 |
|
| 63 |
-
# If
|
| 64 |
-
#
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
|
| 69 |
response = supabase.auth.sign_in_with_oauth({
|
| 70 |
"provider": "google",
|
| 71 |
"options": {
|
| 72 |
-
"redirect_to":
|
| 73 |
}
|
| 74 |
})
|
| 75 |
return response.url
|
| 76 |
except Exception as e:
|
| 77 |
logger.error("Failed to generate Google URL: %s", str(e))
|
| 78 |
raise HTTPException(status_code=500, detail="OAuth Init Failed")
|
| 79 |
-
|
| 80 |
@staticmethod
|
| 81 |
def exchange_code(auth_code: str):
|
| 82 |
try:
|
|
|
|
| 54 |
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e))
|
| 55 |
|
| 56 |
@staticmethod
|
| 57 |
+
def get_google_oauth_url(redirect_to: str = None):
|
| 58 |
try:
|
| 59 |
+
# This is your FastAPI backend callback URL
|
|
|
|
| 60 |
base_callback = "https://hammad712-digitalbillboard.hf.space/auth/callback"
|
| 61 |
|
| 62 |
+
# If redirect_to is 'digital-billboard://', we bake it into the callback URL
|
| 63 |
+
# so it comes back to us in the 'google_callback' function later.
|
| 64 |
+
if redirect_to:
|
| 65 |
+
computed_callback = f"{base_callback}?final_dest={redirect_to}"
|
| 66 |
+
else:
|
| 67 |
+
computed_callback = base_callback
|
| 68 |
|
| 69 |
response = supabase.auth.sign_in_with_oauth({
|
| 70 |
"provider": "google",
|
| 71 |
"options": {
|
| 72 |
+
"redirect_to": computed_callback # Supabase will return the user here
|
| 73 |
}
|
| 74 |
})
|
| 75 |
return response.url
|
| 76 |
except Exception as e:
|
| 77 |
logger.error("Failed to generate Google URL: %s", str(e))
|
| 78 |
raise HTTPException(status_code=500, detail="OAuth Init Failed")
|
| 79 |
+
|
| 80 |
@staticmethod
|
| 81 |
def exchange_code(auth_code: str):
|
| 82 |
try:
|