Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 272 for Reaber (0.15 sec)

  1. tests/test_security_http_bearer_description.py

    security = HTTPBearer(description="HTTP Bearer token scheme")
    
    
    @app.get("/users/me")
    def read_current_user(credentials: HTTPAuthorizationCredentials = Security(security)):
        return {"scheme": credentials.scheme, "credentials": credentials.credentials}
    
    
    client = TestClient(app)
    
    
    def test_security_http_bearer():
        response = client.get("/users/me", headers={"Authorization": "Bearer foobar"})
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2.2K bytes
    - Viewed (0)
  2. tests/test_security_api_key_header.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    api_key = APIKeyHeader(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)
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 1.8K bytes
    - Viewed (0)
  3. fastapi/security/http.py

        The HTTP authorization header value is split by the first space.
    
        The first part is the `scheme`, the second part is the `credentials`.
    
        For example, in an HTTP Bearer token scheme, the client will send a header
        like:
    
        ```
        Authorization: Bearer deadbeef12346
        ```
    
        In this case:
    
        * `scheme` will have the value `"Bearer"`
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 15:29:38 GMT 2024
    - 13.2K bytes
    - Viewed (0)
  4. fastapi/security/oauth2.py

                Doc(
                    """
                    By default, if no HTTP Authorization header is provided, required for
                    OAuth2 authentication, it will automatically cancel the request and
                    send the client an error.
    
                    If `auto_error` is set to `False`, when the HTTP Authorization header
                    is not available, instead of erroring out, the dependency result will
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 21.1K bytes
    - Viewed (1)
  5. docs/de/docs/tutorial/middleware.md

    {!../../../docs_src/middleware/tutorial001.py!}
    ```
    
    !!! tip "Tipp"
        Beachten Sie, dass benutzerdefinierte proprietäre Header hinzugefügt werden können. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">Verwenden Sie dafür das Präfix 'X-'</a>.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Jan 23 11:26:59 GMT 2024
    - 3.4K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_header_params/test_tutorial002_py310.py

    @pytest.fixture(name="client")
    def get_client():
        from docs_src.header_params.tutorial002_py310 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py310
    @pytest.mark.parametrize(
        "path,headers,expected_status,expected_response",
        [
            ("/items", None, 200, {"strange_header": None}),
            ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
            (
                "/items",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 4.2K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_header_params/test_tutorial002_an.py

    from docs_src.header_params.tutorial002_an import app
    
    client = TestClient(app)
    
    
    @pytest.mark.parametrize(
        "path,headers,expected_status,expected_response",
        [
            ("/items", None, 200, {"strange_header": None}),
            ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
            (
                "/items",
                {"strange_header": "FastAPI test"},
                200,
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 4K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_dependencies/test_tutorial012_an.py

    
    def test_get_invalid_second_header_items():
        response = client.get(
            "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
        )
        assert response.status_code == 400, response.text
        assert response.json() == {"detail": "X-Key header invalid"}
    
    
    def test_get_invalid_second_header_users():
        response = client.get(
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 8.4K bytes
    - Viewed (0)
  9. docs_src/dependencies/tutorial006_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI, Header, HTTPException
    
    app = FastAPI()
    
    
    async def verify_token(x_token: Annotated[str, Header()]):
        if x_token != "fake-super-secret-token":
            raise HTTPException(status_code=400, detail="X-Token header invalid")
    
    
    async def verify_key(x_key: Annotated[str, Header()]):
        if x_key != "fake-super-secret-key":
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 633 bytes
    - Viewed (0)
  10. tests/test_tutorial/test_security/test_tutorial005_an.py

        assert response.json() == {"detail": "Not authenticated"}
        assert response.headers["WWW-Authenticate"] == "Bearer"
    
    
    def test_token():
        access_token = get_access_token(scope="me")
        response = client.get(
            "/users/me", headers={"Authorization": f"Bearer {access_token}"}
        )
        assert response.status_code == 200, response.text
        assert response.json() == {
            "username": "johndoe",
    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)
Back to top