- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 57 for get_current_user (0.28 sec)
-
docs/zh/docs/tutorial/security/get-current-user.md
{!../../../docs_src/security/tutorial002.py!} ``` ## 创建 `get_current_user` 依赖项 创建 `get_current_user` 依赖项。 还记得依赖项支持子依赖项吗? `get_current_user` 使用 `oauth2_scheme` 作为依赖项。 与之前直接在路径操作中的做法相同,新的 `get_current_user` 依赖项从子依赖项 `oauth2_scheme` 中接收 `str` 类型的 `token`: ```Python hl_lines="25" {!../../../docs_src/security/tutorial002.py!} ``` ## 获取用户 `get_current_user` 使用创建的(伪)工具函数,该函数接收 `str` 类型的令牌,并返回 Pydantic 的 `User` 模型:
Plain Text - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Mar 30 22:46:46 GMT 2024 - 3.5K bytes - Viewed (0) -
docs_src/security/tutorial002_an_py310.py
username=token + "fakedecoded", email="******@****.***", full_name="John Doe" ) async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]): user = fake_decode_token(token) return user @app.get("/users/me") async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 761 bytes - Viewed (0) -
docs_src/security/tutorial002_an.py
username=token + "fakedecoded", email="******@****.***", full_name="John Doe" ) async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]): user = fake_decode_token(token) return user @app.get("/users/me") async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 815 bytes - Viewed (0) -
docs/ja/docs/tutorial/security/get-current-user.md
```Python hl_lines="5 12-16" {!../../../docs_src/security/tutorial002.py!} ``` ## 依存関係 `get_current_user` を作成 依存関係 `get_current_user` を作ってみましょう。 依存関係はサブ依存関係を持つことができるのを覚えていますか? `get_current_user` は前に作成した `oauth2_scheme` と同じ依存関係を持ちます。 以前直接 *path operation* の中でしていたのと同じように、新しい依存関係である `get_current_user` は `str` として `token` を受け取るようになります: ```Python hl_lines="25" {!../../../docs_src/security/tutorial002.py!} ```
Plain Text - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sun Jan 28 18:36:35 GMT 2024 - 5.6K bytes - Viewed (0) -
docs/zh/docs/advanced/security/oauth2-scopes.md
{!../../../docs_src/security/tutorial005.py!} ``` ## 依赖项树与作用域 再次查看这个依赖项树与作用域。 `get_current_active_user` 依赖项包含子依赖项 `get_current_user`,并在 `get_current_active_user`中声明了作用域 `"me"` 包含所需作用域列表 ,在 `security_scopes.scopes` 中传递给 `get_current_user`。 *路径操作*自身也声明了作用域,`"items"`,这也是 `security_scopes.scopes` 列表传递给 `get_current_user` 的。 依赖项与作用域的层级架构如下: * *路径操作* `read_own_items` 包含: * 依赖项所需的作用域 `["items"]`:
Plain Text - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Mar 30 22:43:35 GMT 2024 - 11.8K bytes - Viewed (0) -
docs_src/security/tutorial002_py310.py
username=token + "fakedecoded", email="******@****.***", full_name="John Doe" ) async def get_current_user(token: str = Depends(oauth2_scheme)): user = fake_decode_token(token) return user @app.get("/users/me") async def read_users_me(current_user: User = Depends(get_current_user)):
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Fri Jan 07 14:11:31 GMT 2022 - 711 bytes - Viewed (0) -
docs_src/security/tutorial002.py
username=token + "fakedecoded", email="******@****.***", full_name="John Doe" ) async def get_current_user(token: str = Depends(oauth2_scheme)): user = fake_decode_token(token) return user @app.get("/users/me") async def read_users_me(current_user: User = Depends(get_current_user)):
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat May 14 11:59:59 GMT 2022 - 755 bytes - Viewed (0) -
docs/em/docs/tutorial/security/get-current-user.md
```Python hl_lines="3 10-14" {!> ../../../docs_src/security/tutorial002_py310.py!} ``` ## ✍ `get_current_user` 🔗 ➡️ ✍ 🔗 `get_current_user`. 💭 👈 🔗 💪 ✔️ 🎧-🔗 ❓ `get_current_user` 🔜 ✔️ 🔗 ⏮️ 🎏 `oauth2_scheme` 👥 ✍ ⏭. 🎏 👥 🔨 ⏭ *➡ 🛠️* 🔗, 👆 🆕 🔗 `get_current_user` 🔜 📨 `token` `str` ⚪️➡️ 🎧-🔗 `oauth2_scheme`: === "🐍 3️⃣.6️⃣ & 🔛" ```Python hl_lines="25"
Plain Text - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Apr 01 09:26:04 GMT 2023 - 4.4K bytes - Viewed (0) -
docs_src/security/tutorial002_an_py39.py
username=token + "fakedecoded", email="******@****.***", full_name="John Doe" ) async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]): user = fake_decode_token(token) return user @app.get("/users/me") async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 786 bytes - Viewed (0) -
tests/test_security_api_key_query.py
app = FastAPI() api_key = APIKeyQuery(name="key") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user @app.get("/users/me") def read_current_user(current_user: User = Depends(get_current_user)): return current_user client = TestClient(app) def test_security_api_key():
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Fri Jun 30 18:25:16 GMT 2023 - 1.8K bytes - Viewed (0)