fastapi docs are outdated.

Hello, I'm trying to configure a fast-api as documented but it seems to miss a few steps . https://docs.kinde.com/developer-tools/sdks/backend/python-sdk/ 1) I get KindeConfigurationException: Client ID is required. when I do fastapi run dev --port 5000. It's fixable with load_env 2) Then, when I hit /login I get "AssertionError: SessionMiddleware must be installed to access request.session" and this is where I'm stuck.
Kinde docs
Python SDK
Complete guide for Python SDK including Flask and FastAPI integration, OAuth configuration, environment variables, and session management for Python 3.9+ applications.
3 Replies
Abdiwak
Abdiwak2w ago
Hi there, Thanks for reaching out. You're encountering two common FastAPI setup issues. The first issue about the Client ID is resolved by loading environment variables, as you mentioned.
For the SessionMiddleware error, you need to add session middleware to your FastAPI app.
from fastapi import FastAPI
from starlette.middleware.sessions import SessionMiddleware
from kinde_sdk.auth.oauth import OAuth

app = FastAPI()
app.add_middleware(SessionMiddleware, secret_key="your-secret-key")

oauth = OAuth(
framework="fastapi",
app=app
)
from fastapi import FastAPI
from starlette.middleware.sessions import SessionMiddleware
from kinde_sdk.auth.oauth import OAuth

app = FastAPI()
app.add_middleware(SessionMiddleware, secret_key="your-secret-key")

oauth = OAuth(
framework="fastapi",
app=app
)
The SessionMiddleware addition comes from FastAPI/Starlette requirements. The Kinde SDK expects session functionality to be available. Please let me know if you have further questions.
shai-tan
shai-tanOP2w ago
That’s right, I found an example that shows it . The point was that the docs (official) are not clear
Abdiwak
Abdiwak2w ago
Hi there,
Thank you for your feedback; we really appreciate it. We are always striving to improve our product, and your insights are truly valuable.
I will reach out to our engineering team regarding your query. Thanks again. FYI, we've raised a PR for the documentation update.

Did you find this page helpful?