Browse Source

add refreshurl to OAuth2PasswordBearer

pull/11460/head
Salar Nosrati-Ershad 1 year ago
parent
commit
f0dc846ea2
  1. 1
      fastapi/openapi/models.py
  2. 12
      fastapi/security/oauth2.py

1
fastapi/openapi/models.py

@ -507,6 +507,7 @@ class OAuthFlowImplicit(OAuthFlow):
class OAuthFlowPassword(OAuthFlow): class OAuthFlowPassword(OAuthFlow):
tokenUrl: str tokenUrl: str
refreshUrl: Optional[str]
class OAuthFlowClientCredentials(OAuthFlow): class OAuthFlowClientCredentials(OAuthFlow):

12
fastapi/security/oauth2.py

@ -408,6 +408,14 @@ class OAuth2PasswordBearer(OAuth2):
""" """
), ),
], ],
refreshUrl: Annotated[
Optional[str],
Doc(
"""
The URL to refresh the token and obtain a new one.
"""
),
],
scheme_name: Annotated[ scheme_name: Annotated[
Optional[str], Optional[str],
Doc( Doc(
@ -461,7 +469,9 @@ class OAuth2PasswordBearer(OAuth2):
if not scopes: if not scopes:
scopes = {} scopes = {}
flows = OAuthFlowsModel( flows = OAuthFlowsModel(
password=cast(Any, {"tokenUrl": tokenUrl, "scopes": scopes}) password=cast(
Any, {"tokenUrl": tokenUrl, "refreshUrl": refreshUrl, "scopes": scopes}
)
) )
super().__init__( super().__init__(
flows=flows, flows=flows,

Loading…
Cancel
Save