From c8c04115a17c100bb401e81c1e0b1f02859ab62d Mon Sep 17 00:00:00 2001 From: Salar Nosrati-Ershad Date: Thu, 18 Apr 2024 20:14:21 +0330 Subject: [PATCH] some fixes --- fastapi/openapi/models.py | 1 - fastapi/security/oauth2.py | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/fastapi/openapi/models.py b/fastapi/openapi/models.py index eb192f750..5f3bdbb20 100644 --- a/fastapi/openapi/models.py +++ b/fastapi/openapi/models.py @@ -507,7 +507,6 @@ class OAuthFlowImplicit(OAuthFlow): class OAuthFlowPassword(OAuthFlow): tokenUrl: str - refreshUrl: Optional[str] class OAuthFlowClientCredentials(OAuthFlow): diff --git a/fastapi/security/oauth2.py b/fastapi/security/oauth2.py index 7ffb121da..43bfd4354 100644 --- a/fastapi/security/oauth2.py +++ b/fastapi/security/oauth2.py @@ -408,14 +408,6 @@ class OAuth2PasswordBearer(OAuth2): """ ), ], - refreshUrl: Annotated[ - Optional[str], - Doc( - """ - The URL to refresh the token and obtain a new one. - """ - ), - ], scheme_name: Annotated[ Optional[str], Doc( @@ -465,12 +457,22 @@ class OAuth2PasswordBearer(OAuth2): """ ), ] = True, + refreshUrl: Annotated[ + Optional[str], + Doc( + """ + The URL to refresh the token and obtain a new one. + """ + ), + ] = None, ): if not scopes: scopes = {} flows = OAuthFlowsModel( password=cast( - Any, {"tokenUrl": tokenUrl, "refreshUrl": refreshUrl, "scopes": scopes} + Any, + {"tokenUrl": tokenUrl, "refreshUrl": refreshUrl, "scopes": scopes} if refreshUrl else + {"tokenUrl": tokenUrl, "scopes": scopes} ) ) super().__init__(