Skip to content

Commit 71a4503

Browse files
committed
refactor conformance string
1 parent 299a079 commit 71a4503

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

openeo/rest/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
DEFAULT_JOB_STATUS_POLL_CONNECTION_RETRY_INTERVAL = 30
1111
DEFAULT_JOB_STATUS_POLL_SOFT_ERROR_MAX = 10
1212

13+
CONFORMANCE_JWT_BEARER = "https://api.openeo.org/*/authentication/jwt"
14+
1315
class OpenEoClientException(BaseOpenEoException):
1416
"""Base class for OpenEO client exceptions"""
1517
pass

openeo/rest/connection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from openeo.metadata import CollectionMetadata
4848
from openeo.rest import (
4949
DEFAULT_DOWNLOAD_CHUNK_SIZE,
50+
CONFORMANCE_JWT_BEARER,
5051
CapabilitiesException,
5152
OpenEoApiError,
5253
OpenEoClientException,
@@ -279,7 +280,7 @@ def authenticate_basic(self, username: Optional[str] = None, password: Optional[
279280
).json()
280281

281282
# check for JWT bearer token conformance
282-
jwt_conformance = self.capabilities().has_conformance("https://api.openeo.org/*/authentication/jwt")
283+
jwt_conformance = self.capabilities().has_conformance(CONFORMANCE_JWT_BEARER)
283284

284285
# Switch to bearer based authentication in further requests.
285286
self.auth = BasicBearerAuth(access_token=resp["access_token"], jwt_conformance = jwt_conformance)
@@ -421,7 +422,7 @@ def _authenticate_oidc(
421422

422423
token = tokens.access_token
423424
# check for JWT bearer token conformance
424-
jwt_conformance = self.capabilities().has_conformance("https://api.openeo.org/*/authentication/jwt")
425+
jwt_conformance = self.capabilities().has_conformance(CONFORMANCE_JWT_BEARER)
425426
self.auth = OidcBearerAuth(provider_id=provider_id, access_token=token, jwt_conformance=jwt_conformance)
426427
self._oidc_auth_renewer = oidc_auth_renewer
427428
return self

0 commit comments

Comments
 (0)