]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✨ Add `refreshUrl` parameter in `OAuth2PasswordBearer` (#11460)
authorSalar Nosrati-Ershad <snosratiershad@gmail.com>
Tue, 17 Jun 2025 10:46:49 +0000 (14:16 +0330)
committerGitHub <noreply@github.com>
Tue, 17 Jun 2025 10:46:49 +0000 (12:46 +0200)
Co-authored-by: Salar Nosrati-Ershad <s3r@tutamail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
fastapi/security/oauth2.py

index 42ace07a3458b8468b631594416d4cfc778de7f7..88e394db1100fc3080f01e3235867948cb2863c7 100644 (file)
@@ -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,