openapi-python-sdk icon indicating copy to clipboard operation
openapi-python-sdk copied to clipboard

OAuth token request fails when used inside FastAPI dependency with request timeout

Open francescobianco opened this issue 8 months ago • 0 comments

OAuth token request fails when used inside FastAPI dependency with request timeout

Description
When using the SDK inside a FastAPI dependency, token creation fails if the request context times out.

Code snippet

from fastapi import Depends, FastAPI
from openapi_sdk import OauthClient

app = FastAPI()

def get_token():
    client = OauthClient("user", "apikey", test=True)
    return client.create_token(["scope"], 3600)

@app.get("/")
def read_root(token=Depends(get_token)):
    return {"token": token}

Observed behavior
Occasional timeout errors or incomplete responses.

Expected behavior
Token generation should be resilient to request lifecycle timing.

francescobianco avatar Mar 18 '26 14:03 francescobianco