Skip to content

Commit 35ffade

Browse files
committed
fix(ninja): small fix
1 parent f1f996f commit 35ffade

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "cardo-python-utils"
7-
version = "0.5.dev55"
7+
version = "0.5.dev56"
88
description = "Python library enhanced with a wide range of functions for different scenarios."
99
readme = "README.rst"
1010
requires-python = ">=3.8"

python_utils/django/api/ninja.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.conf import settings
77
from django.http import HttpRequest
88
from ninja.security import HttpBearer
9-
from ninja.errors import AuthenticationError, AuthorizationError, HttpError
9+
from ninja.errors import AuthenticationError, HttpError
1010

1111
from .utils import (
1212
acreate_or_update_user,
@@ -64,13 +64,13 @@ def _decode_token(self, token: str) -> TokenPayload:
6464
except ExpiredSignatureError as e:
6565
raise AuthenticationError("Token has expired.") from e
6666
except (InvalidTokenError, PyJWKClientError) as e:
67-
raise AuthorizationError(f"Invalid token: {str(e)}") from e
67+
raise AuthenticationError(f"Invalid token: {str(e)}") from e
6868

6969
def _get_username(self, payload: TokenPayload) -> str:
7070
try:
7171
return payload["preferred_username"]
7272
except KeyError as e:
73-
raise AuthorizationError("Invalid token: 'preferred_username' claim not present.") from e
73+
raise AuthenticationError("Invalid token: 'preferred_username' claim not present.") from e
7474

7575
def _verify_scopes(self, request, token_payload):
7676
allowed_scopes = self._get_view_allowed_scopes(request)

0 commit comments

Comments
 (0)