Added cognito authentication - Fix 11
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m11s
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m11s
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
from fastapi import FastAPI, Depends, HTTPException
|
from fastapi import FastAPI, Depends, HTTPException, Request
|
||||||
from fastapi.responses import JSONResponse, RedirectResponse
|
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
|
from app.cabletv.utils.auth import exchange_code_for_token, get_current_user, DOMAIN, CLIENT_ID
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
@@ -16,7 +15,7 @@ async def protected_route(user = Depends(get_current_user)):
|
|||||||
return {"message": "Protected content", "user": user['Username']}
|
return {"message": "Protected content", "user": user['Username']}
|
||||||
|
|
||||||
@app.get("/auth/callback")
|
@app.get("/auth/callback")
|
||||||
async def auth_callback(code: str):
|
async def auth_callback(request: Request, code: str):
|
||||||
try:
|
try:
|
||||||
redirect_uri = str(request.base_url) + "auth/callback"
|
redirect_uri = str(request.base_url) + "auth/callback"
|
||||||
tokens = exchange_code_for_token(code, redirect_uri)
|
tokens = exchange_code_for_token(code, redirect_uri)
|
||||||
|
|||||||
Reference in New Issue
Block a user