Cosmetic
This commit is contained in:
parent
78ce6fd01a
commit
e13b7e1e29
1 changed files with 3 additions and 2 deletions
|
@ -13,6 +13,7 @@ from fastapi.security import (
|
||||||
OAuth2AuthorizationCodeBearer,
|
OAuth2AuthorizationCodeBearer,
|
||||||
)
|
)
|
||||||
from starlette.middleware.sessions import SessionMiddleware
|
from starlette.middleware.sessions import SessionMiddleware
|
||||||
|
from authlib.integrations.starlette_client.apps import StarletteOAuth2App
|
||||||
from authlib.integrations.starlette_client import OAuth, OAuthError
|
from authlib.integrations.starlette_client import OAuth, OAuthError
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from pydantic_settings import (
|
from pydantic_settings import (
|
||||||
|
@ -174,7 +175,7 @@ async def current_user(request: Request, token: str | None = Depends(fastapi_oau
|
||||||
async def login(request: Request, provider: str) -> RedirectResponse:
|
async def login(request: Request, provider: str) -> RedirectResponse:
|
||||||
redirect_uri = request.url_for("auth", provider=provider)
|
redirect_uri = request.url_for("auth", provider=provider)
|
||||||
try:
|
try:
|
||||||
provider_ = getattr(authlib_oauth, provider)
|
provider_: StarletteOAuth2App = getattr(authlib_oauth, provider)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise HTTPException(500, "")
|
raise HTTPException(500, "")
|
||||||
try:
|
try:
|
||||||
|
@ -186,7 +187,7 @@ async def login(request: Request, provider: str) -> RedirectResponse:
|
||||||
@app.get("/auth/{provider}")
|
@app.get("/auth/{provider}")
|
||||||
async def auth(request: Request, provider: str) -> RedirectResponse:
|
async def auth(request: Request, provider: str) -> RedirectResponse:
|
||||||
try:
|
try:
|
||||||
provider_ = getattr(authlib_oauth, provider)
|
provider_: StarletteOAuth2App = getattr(authlib_oauth, provider)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise HTTPException(500, "")
|
raise HTTPException(500, "")
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue