Skip to content

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

Description

@francescobianco

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions