redirect_uri is not authorized for this client #444
-
I have used the following code to start the fief client ( from os import getenv
from dotenv import load_dotenv
from fastapi import Depends, FastAPI
from fastapi.security import OAuth2AuthorizationCodeBearer
from fief_client import FiefAccessTokenInfo, FiefAsync
from fief_client.integrations.fastapi import FiefAuth
load_dotenv()
fief = FiefAsync(
"http://localhost:8000",
getenv("CLIENT_ID"),
getenv("CLIENT_SECRET"),
)
scheme = OAuth2AuthorizationCodeBearer(
"http://localhost:8000/authorize",
"http://localhost:8000/api/token",
scopes={"openid": "openid", "offline_access": "offline_access"},
auto_error=False,
)
auth = FiefAuth(fief, scheme)
app = FastAPI()
@app.get("/user")
async def get_user(access_token_info: FiefAccessTokenInfo = Depends(auth.authenticated())):
return access_token_info I have used the following command to start the uvicorn server ( $ uvicorn main:app --host localhost --port 5000 --reload
Fief Server: localhost:8000 I follow the steps mentioned in the API Section of the FastAPI After I enter the
I see the following url in the address bar of the browser
I believe the To ReproduceSteps to reproduce the behavior:
Expected behavior
Configuration
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hail, @KXN2004 👋 Welcome to Fief's kingdom! Our team will get back to you very soon to help. In the meantime, take a minute to star our repository ⭐️ Want to support us?Subscribe to one of our paid plan to help us continue our work and receive exclusive information and benefits! Starts at $5/month 🪙 Farewell! |
Beta Was this translation helpful? Give feedback.
-
You need to authorize If you start the authentication from the Swagger docs on |
Beta Was this translation helpful? Give feedback.
You need to authorize
http://localhost:5000/docs/oauth2-redirect
as as redirect URI in your Client configuration: https://docs.fief.dev/configure/clients/#redirect-urisIf you start the authentication from the Swagger docs on
localhost:5000
, then it'll try to redirect the same Swagger onlocalhost:5000
; but you need to tell Fief it's safe to do so.