Open ldorigo opened 9 months ago
I'm a bit confused... The error is shown even when you add the middleware? By what you've shown, your code is not setting the framework cache, as it should have been done in oauth creation. Do you intend to use the cache or the session approach?
I'm confused too, that's the point :-) The docs aren't clear.
That error is not shown when I add the middleware - I used to have an entirely different error, however it disappeared now and I'm not sure why, I don't think I changed anything - maybe it was related to the browser's cache.
But according to the docs, it's not necessary to use session middleware with Starlette for OAuth2, which doesn't appear to be true?
Yeah, I guess the docs are misleading or incomplete. You must either use the starlette session middleware or setup the cache service (which is only described in flask configuration for some reason)
Describe the bug
The documentation for the FastAPI/starlette clients for Oauth2 are unclear. In Starlette, it says that it's not necessary to use SessionMiddleware for OAuth2, yet in FastAPI (Which uses the exact same client), it seems to say that it is necessary? indeed, if I don't include the middleware, I get an error saying that "SessionMiddleware must be installed to access request.session"?
This was supposedly fixed in https://github.com/lepture/authlib/issues/425 (commit https://github.com/lepture/authlib/commit/1089d5441c8e780a5165ca859b289fc8485ec5eb ), but that doesn't work:
framework.cache
isNone
in my case, and the docs don't say anywhere where/how to initialize it?Note that adding the
SessionMiddleware
doesn't work either, although that seems to be a separate bug. Happy to expand if necessary.Code
Environment: