Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 92 for scope (0.35 sec)

  1. tests/test_route_scope.py

    
    @app.get("/users/{user_id}")
    async def get_user(user_id: str, request: Request):
        route: APIRoute = request.scope["route"]
        return {"user_id": user_id, "path": route.path}
    
    
    @app.websocket("/items/{item_id}")
    async def websocket_item(item_id: str, websocket: WebSocket):
        route: APIWebSocketRoute = websocket.scope["route"]
        await websocket.accept()
        await websocket.send_json({"item_id": item_id, "path": route.path})
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Feb 08 10:23:07 GMT 2023
    - 1.5K bytes
    - Viewed (0)
  2. fastapi/security/oauth2.py

            data = {}
            data["scopes"] = []
            for scope in form_data.scopes:
                data["scopes"].append(scope)
            if form_data.client_id:
                data["client_id"] = form_data.client_id
            if form_data.client_secret:
                data["client_secret"] = form_data.client_secret
            return data
        ```
    
        Note that for OAuth2 the scope `items:read` is a single scope in an opaque string.
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 21.1K bytes
    - Viewed (1)
  3. tests/test_tutorial/test_security/test_tutorial005_an.py

        fake_users_db,
        get_password_hash,
        verify_password,
    )
    
    client = TestClient(app)
    
    
    def get_access_token(username="johndoe", password="secret", scope=None):
        data = {"username": username, "password": password}
        if scope:
            data["scope"] = scope
        response = client.post("/token", data=data)
        content = response.json()
        access_token = content.get("access_token")
        return access_token
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 15.4K bytes
    - Viewed (0)
  4. docs/em/docs/advanced/security/oauth2-scopes.md

                        * 🔗 ⚙️ `oauth2_scheme`.
                        *  `security_scopes` 🔢 🆎 `SecurityScopes`:
                            * 👉 `security_scopes` 🔢 ✔️ 🏠 `scopes` ⏮️ `list` ⚗ 🌐 👫 ↔ 📣 🔛,:
                                * `security_scopes.scopes` 🔜 🔌 `["me", "items"]` *➡ 🛠️* `read_own_items`.
                                * `security_scopes.scopes` 🔜 🔌 `["me"]` *➡ 🛠️* `read_users_me`, ↩️ ⚫️ 📣 🔗 `get_current_active_user`.
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Jan 11 21:21:35 GMT 2024
    - 11.1K bytes
    - Viewed (0)
  5. docs/zh/docs/advanced/custom-request-and-route.md

    ```Python hl_lines="18-26"
    {!../../../docs_src/custom_request_and_route/tutorial001.py!}
    ```
    
    !!! note "技术细节"
    
        `Request` 的 `request.scope` 属性是包含关联请求元数据的字典。
    
        `Request` 的 `request.receive` 方法是**接收**请求体的函数。
    
        `scope` 字典与 `receive` 函数都是 ASGI 规范的内容。
    
        `scope` 与 `receive` 也是创建新的 `Request` 实例所需的。
    
    Plain Text
    - Registered: Sun Mar 31 07:19:09 GMT 2024
    - Last Modified: Sat Mar 30 22:45:40 GMT 2024
    - 3.8K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_security/test_tutorial005_py39.py

        client = TestClient(app)
        return client
    
    
    def get_access_token(
        *, username="johndoe", password="secret", scope=None, client: TestClient
    ):
        data = {"username": username, "password": password}
        if scope:
            data["scope"] = scope
        response = client.post("/token", data=data)
        content = response.json()
        access_token = content.get("access_token")
        return access_token
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 16.3K bytes
    - Viewed (0)
  7. docs_src/security/tutorial005_an.py

                raise credentials_exception
            token_scopes = payload.get("scopes", [])
            token_data = TokenData(scopes=token_scopes, username=username)
        except (JWTError, ValidationError):
            raise credentials_exception
        user = get_user(fake_users_db, username=token_data.username)
        if user is None:
            raise credentials_exception
        for scope in security_scopes.scopes:
            if scope not in token_data.scopes:
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 5.3K bytes
    - Viewed (0)
  8. docs/zh/docs/tutorial/security/simple-oauth2.md

    不过也不用担心,前端仍可以显示终端用户所需的名称。
    
    数据库模型也可以使用所需的名称。
    
    但对于登录*路径操作*,则要使用兼容规范的 `username` 和 `password`,(例如,实现与 API 文档集成)。
    
    该规范要求必须以表单数据形式发送 `username` 和 `password`,因此,不能使用 JSON 对象。
    
    ### `Scope`(作用域)
    
    OAuth2 还支持客户端发送**`scope`**表单字段。
    
    虽然表单字段的名称是 `scope`(单数),但实际上,它是以空格分隔的,由多个**scope**组成的长字符串。
    
    **作用域**只是不带空格的字符串。
    
    常用于声明指定安全权限,例如:
    
    * 常见用例为,`users:read` 或 `users:write`
    * 脸书和 Instagram 使用 `instagram_basic`
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 8.8K bytes
    - Viewed (0)
  9. tests/test_ws_router.py

            @functools.wraps(app)
            async def wrapped_app(scope, receive, send):
                if scope["type"] != "websocket":
                    return await app(scope, receive, send)  # pragma: no cover
    
                async def call_next():
                    return await app(scope, receive, send)
    
                websocket = WebSocket(scope, receive=receive, send=send)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  10. docs/en/docs/how-to/custom-request-and-route.md

    ```
    
    !!! note "Technical Details"
        A `Request` has a `request.scope` attribute, that's just a Python `dict` containing the metadata related to the request.
    
        A `Request` also has a `request.receive`, that's a function to "receive" the body of the request.
    
        The `scope` `dict` and `receive` function are both part of the ASGI specification.
    
        And those two things, `scope` and `receive`, are what is needed to create a new `Request` instance.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Mar 31 23:52:53 GMT 2024
    - 4.4K bytes
    - Viewed (0)
Back to top