Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 17 for make_not_authenticated_error (0.64 seconds)

  1. docs/ja/docs/how-to/authentication-error-status-code.md

    しかし、何らかの理由でクライアントが従来の挙動に依存している場合は、セキュリティクラスでメソッド `make_not_authenticated_error` をオーバーライドすることで、その挙動に戻せます。
    
    たとえば、既定の `401 Unauthorized` エラーの代わりに `403 Forbidden` エラーを返す `HTTPBearer` のサブクラスを作成できます:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 1.4K bytes
    - Click Count (0)
  2. docs_src/authentication_error_status_code/tutorial001_an_py310.py

    from fastapi import Depends, FastAPI, HTTPException, status
    from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
    
    app = FastAPI()
    
    
    class HTTPBearer403(HTTPBearer):
        def make_not_authenticated_error(self) -> HTTPException:
            return HTTPException(
                status_code=status.HTTP_403_FORBIDDEN, detail="Not authenticated"
            )
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 618 bytes
    - Click Count (0)
  3. docs/en/docs/how-to/authentication-error-status-code.md

    But if for some reason your clients depend on the old behavior, you can revert to it by overriding the method `make_not_authenticated_error` in your security classes.
    
    For example, you can create a subclass of `HTTPBearer` that returns a `403 Forbidden` error instead of the default `401 Unauthorized` error:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 1.2K bytes
    - Click Count (0)
  4. fastapi/security/open_id_connect_url.py

                openIdConnectUrl=openIdConnectUrl, description=description
            )
            self.scheme_name = scheme_name or self.__class__.__name__
            self.auto_error = auto_error
    
        def make_not_authenticated_error(self) -> HTTPException:
            return HTTPException(
                status_code=HTTP_401_UNAUTHORIZED,
                detail="Not authenticated",
                headers={"WWW-Authenticate": "Bearer"},
            )
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Mar 16 10:16:48 GMT 2026
    - 3.1K bytes
    - Click Count (0)
  5. docs/zh-hant/docs/how-to/authentication-error-status-code.md

    但如果你的用戶端因某些原因依賴於舊行為,你可以在你的 security 類別中覆寫 `make_not_authenticated_error` 方法以恢復舊的行為。
    
    例如,你可以建立 `HTTPBearer` 的子類別,讓它回傳 `403 Forbidden` 錯誤,而不是預設的 `401 Unauthorized` 錯誤:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    
    /// tip
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 1.1K bytes
    - Click Count (0)
  6. docs/ko/docs/how-to/authentication-error-status-code.md

    하지만 어떤 이유로든 클라이언트가 이전 동작에 의존하고 있다면, 보안 클래스에서 `make_not_authenticated_error` 메서드를 오버라이드하여 이전 동작으로 되돌릴 수 있습니다.
    
    예를 들어, 기본값인 `401 Unauthorized` 오류 대신 `403 Forbidden` 오류를 반환하는 `HTTPBearer`의 서브클래스를 만들 수 있습니다:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:06:26 GMT 2026
    - 1.3K bytes
    - Click Count (0)
  7. docs/zh/docs/how-to/authentication-error-status-code.md

    但如果由于某些原因你的客户端依赖旧行为,你可以在你的安全类中重写方法 `make_not_authenticated_error` 来回退到旧行为。
    
    例如,你可以创建一个 `HTTPBearer` 的子类,使其返回 `403 Forbidden` 错误,而不是默认的 `401 Unauthorized` 错误:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    
    /// tip | 提示
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 1.1K bytes
    - Click Count (0)
  8. fastapi/security/http.py

                if self.auto_error:
                    raise self.make_not_authenticated_error()
                else:
                    return None
            try:
                data = b64decode(param).decode("ascii")
            except (ValueError, UnicodeDecodeError, binascii.Error) as e:
                raise self.make_not_authenticated_error() from e
            username, separator, password = data.partition(":")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Mar 16 10:16:48 GMT 2026
    - 13.1K bytes
    - Click Count (0)
  9. fastapi/security/api_key.py

                name=name,
                description=description,
            )
            self.scheme_name = scheme_name or self.__class__.__name__
    
        def make_not_authenticated_error(self) -> HTTPException:
            """
            The WWW-Authenticate header is not standardized for API Key authentication but
            the HTTP specification requires that an error of 401 "Unauthorized" must
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 9.6K bytes
    - Click Count (1)
  10. fastapi/security/oauth2.py

                flows=cast(OAuthFlowsModel, flows), description=description
            )
            self.scheme_name = scheme_name or self.__class__.__name__
            self.auto_error = auto_error
    
        def make_not_authenticated_error(self) -> HTTPException:
            """
            The OAuth 2 specification doesn't define the challenge that should be used,
            because a `Bearer` token is not really the only option to authenticate.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Mar 24 16:32:10 GMT 2026
    - 23.6K bytes
    - Click Count (0)
Back to Top