Browse Source

Add `refreshUrl` parameter in `OAuth2PasswordBearer` (#11460)

Co-authored-by: Salar Nosrati-Ershad <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alejandra <[email protected]>
Co-authored-by: Motov Yurii <[email protected]>
pull/13793/merge
Salar Nosrati-Ershad 3 days ago
committed by GitHub
parent
commit
aebff5006f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      fastapi/security/oauth2.py

17
fastapi/security/oauth2.py

@ -457,11 +457,26 @@ 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, "scopes": scopes})
password=cast(
Any,
{
"tokenUrl": tokenUrl,
"refreshUrl": refreshUrl,
"scopes": scopes,
},
)
)
super().__init__(
flows=flows,

Loading…
Cancel
Save