Skip to content

Commit 500cf5c

Browse files
authored
Merge pull request #511 from sentinel-hub/develop
Release 3.10.0
2 parents 34193fd + 6616e79 commit 500cf5c

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

CHANGELOG.MD

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [Version 3.10.0] - 2023-12-07
2+
3+
- Adjust session caching to mirror changes to the core services. Older version might no longer correctly cache sessions.
4+
15
## [Version 3.9.5] - 2023-12-07
26

37
- The `SentinelHubDownloadClient` class now has a `default_retry_time` parameter, which allows control over the waiting time when a request gets a 429 TOO_MANY_REQUESTS response without a specific retry time in the headers. The default value for this behavior has been changed from 0s to 30s to avoid edge-cases where SH services were bombarded with requests.

sentinelhub/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of the sentinelhub package."""
22

3-
__version__ = "3.9.5"
3+
__version__ = "3.10.0"

sentinelhub/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class _SHConfig:
3030
sh_client_secret: str = ""
3131
sh_base_url: str = "https://services.sentinel-hub.com"
3232
sh_auth_base_url: str | None = None
33-
sh_token_url: str = "https://services.sentinel-hub.com/oauth/token"
33+
sh_token_url: str = "https://services.sentinel-hub.com/auth/realms/main/protocol/openid-connect/token"
3434
geopedia_wms_url: str = "https://service.geopedia.world"
3535
geopedia_rest_url: str = "https://www.geopedia.world/rest"
3636
aws_access_key_id: str = ""

sentinelhub/download/sentinelhub_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _get_cache_key(config_or_session: SentinelHubSession | SHConfig) -> tuple[st
194194
base_url = config_or_session.config.sh_base_url
195195

196196
# If session was generated from token then config_or_session.config.sh_client_id could have wrong client id.
197-
sh_client_id = config_or_session.info().get("aud", "")
197+
sh_client_id = config_or_session.info().get("azp", "")
198198
if not sh_client_id:
199199
warnings.warn(
200200
"Failed to read client ID from OAuth token. Session caching might not work correctly.",

tests/api/test_process.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Any
88

99
import pytest
10-
from oauthlib.oauth2.rfc6749.errors import CustomOAuth2Error
10+
from oauthlib.oauth2.rfc6749.errors import InvalidClientError
1111
from shapely.geometry import Polygon
1212

1313
from sentinelhub import (
@@ -483,7 +483,7 @@ def test_bad_credentials() -> None:
483483
bad_credentials_config.sh_client_id = "test"
484484

485485
request = SentinelHubRequest(**request_params, config=bad_credentials_config)
486-
with pytest.raises(CustomOAuth2Error):
486+
with pytest.raises(InvalidClientError):
487487
request.get_data()
488488

489489
missing_credentials_config = SHConfig()

tests/download/test_session.py

+6-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Any
66

77
import pytest
8-
from oauthlib.oauth2.rfc6749.errors import CustomOAuth2Error
8+
from oauthlib.oauth2.rfc6749.errors import CustomOAuth2Error, InvalidClientError
99
from requests_mock import Mocker
1010

1111
from sentinelhub import SentinelHubSession, SHConfig, __version__
@@ -48,15 +48,12 @@ def test_session(session: SentinelHubSession) -> None:
4848

4949
@pytest.mark.sh_integration()
5050
def test_token_info(session: SentinelHubSession) -> None:
51-
info = session.info()
52-
53-
for key in ["sub", "aud", "jti", "exp", "name", "email", "sid", "org", "did", "aid", "d"]:
54-
assert key in info
51+
assert "azp" in session.info()
5552

5653

5754
def test_session_content_and_headers(fake_config: SHConfig, fake_token: dict[str, Any], requests_mock: Mocker) -> None:
5855
"""Make sure correct content and headers are passed to the service."""
59-
requests_mock.post(url="/oauth/token", response_list=[{"json": fake_token}])
56+
requests_mock.post(url=fake_config.sh_token_url, response_list=[{"json": fake_token}])
6057
call_time = time.time()
6158
token = SentinelHubSession(config=fake_config).token
6259
# "expires_at" is derived from "expires_in" and not read from the response field "expires_at"
@@ -108,7 +105,7 @@ def test_refreshing_procedure(fake_token: JsonDict, fake_config: SHConfig) -> No
108105
assert session.token == fake_token
109106

110107
session = SentinelHubSession(config=fake_config, refresh_before_expiry=500, _token=fake_token)
111-
with pytest.raises(CustomOAuth2Error):
108+
with pytest.raises(InvalidClientError):
112109
_ = session.token
113110

114111

@@ -128,11 +125,7 @@ def test_oauth_compliance_hook_4xx(
128125
expected_exception: type[Exception],
129126
fake_config: SHConfig,
130127
) -> None:
131-
requests_mock.post(
132-
"https://services.sentinel-hub.com/oauth/token",
133-
json=response_payload,
134-
status_code=status_code,
135-
)
128+
requests_mock.post(fake_config.sh_token_url, json=response_payload, status_code=status_code)
136129

137130
with pytest.raises(expected_exception):
138131
SentinelHubSession(config=fake_config)
@@ -151,11 +144,7 @@ def test_oauth_compliance_hook_4xx(
151144
def test_oauth_compliance_hook_5xx(
152145
requests_mock: Mocker, status_code: int, response_payload: JsonDict | None, fake_config: SHConfig
153146
) -> None:
154-
requests_mock.post(
155-
"https://services.sentinel-hub.com/oauth/token",
156-
json=response_payload,
157-
status_code=status_code,
158-
)
147+
requests_mock.post(fake_config.sh_token_url, json=response_payload, status_code=status_code)
159148

160149
fake_config.max_download_attempts = 10
161150
fake_config.download_sleep_time = 0

0 commit comments

Comments
 (0)