Added cognito authentication - Fix 10
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m9s
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m9s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from fastapi import FastAPI, Depends, HTTPException
|
||||
from fastapi.responses import JSONResponse, RedirectResponse
|
||||
from requests import request
|
||||
from app.cabletv.utils.auth import exchange_code_for_token, get_current_user, DOMAIN, CLIENT_ID
|
||||
|
||||
app = FastAPI()
|
||||
@@ -17,15 +18,14 @@ async def protected_route(user = Depends(get_current_user)):
|
||||
@app.get("/auth/callback")
|
||||
async def auth_callback(code: str):
|
||||
try:
|
||||
tokens = exchange_code_for_token(code)
|
||||
redirect_uri = str(request.base_url) + "auth/callback"
|
||||
tokens = exchange_code_for_token(code, redirect_uri)
|
||||
|
||||
# Use id_token
|
||||
response = JSONResponse(content={
|
||||
"message": "Authentication successful",
|
||||
"id_token": tokens["id_token"] # Changed from access_token
|
||||
})
|
||||
|
||||
# Store id_token in cookie
|
||||
response.set_cookie(
|
||||
key="token",
|
||||
value=tokens["id_token"], # Changed from access_token
|
||||
|
||||
Reference in New Issue
Block a user