- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 38 for tokenUrl (0.14 seconds)
-
tests/test_security_oauth2_authorization_code_bearer.py
from fastapi.testclient import TestClient from inline_snapshot import snapshot app = FastAPI() oauth2_scheme = OAuth2AuthorizationCodeBearer( authorizationUrl="authorize", tokenUrl="token", auto_error=True ) @app.get("/items/") async def read_items(token: str | None = Security(oauth2_scheme)): return {"token": token} client = TestClient(app) def test_no_token():
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 2.7K bytes - Click Count (0) -
tests/test_security_oauth2_password_bearer_optional_description.py
from fastapi.security import OAuth2PasswordBearer from fastapi.testclient import TestClient from inline_snapshot import snapshot app = FastAPI() oauth2_scheme = OAuth2PasswordBearer( tokenUrl="/token", description="OAuth2PasswordBearer security scheme", auto_error=False, ) @app.get("/items/") async def read_items(token: str | None = Security(oauth2_scheme)): if token is None:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 2.4K bytes - Click Count (0) -
tests/test_security_oauth2_authorization_code_bearer_description.py
from fastapi.testclient import TestClient from inline_snapshot import snapshot app = FastAPI() oauth2_scheme = OAuth2AuthorizationCodeBearer( authorizationUrl="authorize", tokenUrl="token", description="OAuth2 Code Bearer", auto_error=True, ) @app.get("/items/") async def read_items(token: str | None = Security(oauth2_scheme)): return {"token": token}
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 2.5K bytes - Click Count (0) -
tests/test_security_oauth2_password_bearer_optional.py
from fastapi import FastAPI, Security from fastapi.security import OAuth2PasswordBearer from fastapi.testclient import TestClient from inline_snapshot import snapshot app = FastAPI() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token", auto_error=False) @app.get("/items/") async def read_items(token: str | None = Security(oauth2_scheme)): if token is None: return {"msg": "Create an account first"} return {"token": token}
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 2.2K bytes - Click Count (0) -
docs/ko/docs/tutorial/security/first-steps.md
그런 경우를 위해서도 **FastAPI**는 이를 구성할 수 있는 도구를 제공합니다. /// `OAuth2PasswordBearer` 클래스의 인스턴스를 만들 때 `tokenUrl` 파라미터를 전달합니다. 이 파라미터에는 클라이언트(사용자의 브라우저에서 실행되는 frontend)가 token을 받기 위해 `username`과 `password`를 보낼 URL이 들어 있습니다. {* ../../docs_src/security/tutorial001_an_py310.py hl[8] *} /// tip | 팁 여기서 `tokenUrl="token"`은 아직 만들지 않은 상대 URL `token`을 가리킵니다. 상대 URL이므로 `./token`과 동일합니다.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:06:26 GMT 2026 - 9.6K bytes - Click Count (0) -
docs/en/docs/tutorial/security/first-steps.md
/// When we create an instance of the `OAuth2PasswordBearer` class we pass in the `tokenUrl` parameter. This parameter contains the URL that the client (the frontend running in the user's browser) will use to send the `username` and `password` in order to get a token. {* ../../docs_src/security/tutorial001_an_py310.py hl[8] *} /// tip
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Mar 07 09:29:03 GMT 2026 - 8.3K bytes - Click Count (0) -
docs_src/security/tutorial001_an_py310.py
from typing import Annotated from fastapi import Depends, FastAPI from fastapi.security import OAuth2PasswordBearer app = FastAPI() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") @app.get("/items/") async def read_items(token: Annotated[str, Depends(oauth2_scheme)]):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 309 bytes - Click Count (0) -
docs/zh-hant/docs/tutorial/security/first-steps.md
通常對多數情境也足夠,除非你是 OAuth2 專家並確信有更適合你的選項。 在那種情況下,FastAPI 也提供相應工具讓你自行組合。 /// 當我們建立 `OAuth2PasswordBearer` 類別的實例時,會傳入 `tokenUrl` 參數。這個參數包含了客戶端(在使用者瀏覽器中執行的前端)用來送出 `username` 與 `password` 以取得 token 的 URL。 {* ../../docs_src/security/tutorial001_an_py310.py hl[8] *} /// tip 這裡的 `tokenUrl="token"` 指的是尚未建立的相對 URL `token`。因為是相對 URL,所以等同於 `./token`。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 7.2K bytes - Click Count (0) -
docs/zh/docs/tutorial/security/first-steps.md
对于大多数用例,它也可能是最佳选择,除非你是 OAuth2 专家,并明确知道为何其他方案更适合你的需求。 在那种情况下,**FastAPI** 同样提供了相应的构建工具。 /// 创建 `OAuth2PasswordBearer` 类实例时,需要传入 `tokenUrl` 参数。该参数包含客户端(运行在用户浏览器中的前端)用来发送 `username` 和 `password` 以获取令牌的 URL。 {* ../../docs_src/security/tutorial001_an_py310.py hl[8] *} /// tip | 提示 这里的 `tokenUrl="token"` 指向的是尚未创建的相对 URL `token`,等价于 `./token`。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:06:37 GMT 2026 - 7.5K bytes - Click Count (0) -
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py
from fastapi.testclient import TestClient from inline_snapshot import snapshot oauth2_scheme = OAuth2AuthorizationCodeBearer( authorizationUrl="api/oauth/authorize", tokenUrl="/api/oauth/token", scopes={"read": "Read access", "write": "Write access"}, ) async def get_token(token: Annotated[str, Depends(oauth2_scheme)]) -> str: return token
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 2.6K bytes - Click Count (0)