eodash_catalog 0.0.34__py3-none-any.whl → 0.0.36__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of eodash_catalog might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Daniel Santillan <daniel.santillan@eox.at>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.0.34"
4
+ __version__ = "0.0.36"
@@ -1,10 +1,11 @@
1
1
  import os
2
+ import time
2
3
 
3
4
  from oauthlib.oauth2 import BackendApplicationClient
4
5
  from requests_oauthlib import OAuth2Session
5
6
 
6
7
  SH_TOKEN_URL = "https://services.sentinel-hub.com/oauth/token"
7
- _token_cache: dict[str, str] = {}
8
+ _token_cache: dict[str, dict] = {}
8
9
 
9
10
 
10
11
  def get_SH_token(endpoint_config: dict) -> str:
@@ -14,8 +15,10 @@ def get_SH_token(endpoint_config: dict) -> str:
14
15
  if env_id := endpoint_config.get("CustomSHEnvId"):
15
16
  client_id = os.getenv(f"SH_CLIENT_ID_{env_id}", "")
16
17
  client_secret = os.getenv(f"SH_CLIENT_SECRET_{env_id}", "")
17
- if client_id in _token_cache:
18
- return _token_cache[client_id]
18
+ # 10 minutes before end of validity
19
+ safety_buffer_validity = _token_cache[client_id]["expires_at"] - (60 * 10)
20
+ if client_id in _token_cache and (safety_buffer_validity) > (time.time()):
21
+ return _token_cache[client_id]["access_token"]
19
22
  # Create a session
20
23
  client = BackendApplicationClient(client_id=client_id)
21
24
  oauth = OAuth2Session(client=client)
@@ -25,6 +28,5 @@ def get_SH_token(endpoint_config: dict) -> str:
25
28
  client_secret=client_secret,
26
29
  )
27
30
  access_token = token["access_token"]
28
- _token_cache[client_id] = access_token
29
-
31
+ _token_cache[client_id] = {"access_token": access_token, "expires_at": token["expires_at"]}
30
32
  return access_token
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eodash_catalog
3
- Version: 0.0.34
3
+ Version: 0.0.36
4
4
  Summary: This package is intended to help create a compatible STAC catalog for the eodash dashboard client. It supports configuration of multiple endpoint types for information extraction.
5
5
  Project-URL: Documentation, https://github.com/eodash/eodash_catalog#readme
6
6
  Project-URL: Issues, https://github.com/eodash/eodash_catalog/issues
@@ -1,14 +1,14 @@
1
- eodash_catalog/__about__.py,sha256=E85nFpHWi4zVhfnqROklSKnFZhc9qXPdY62-2YS2AXY,138
1
+ eodash_catalog/__about__.py,sha256=ZvI8Z-KTcpq5DLukULoS0cmTKFk8JeJK8R6ejONrZF4,138
2
2
  eodash_catalog/__init__.py,sha256=_W_9emPYf6FUqc0P8L2SmADx6hGSd7PlQV3yRmCk5uM,115
3
3
  eodash_catalog/duration.py,sha256=B6XOZfvNU7SuqpxuVtT1kNKODoOQJXDI6mocvA_U1ik,10816
4
4
  eodash_catalog/endpoints.py,sha256=9cSdB_IczNW9hzOJRrI5_qmgsn4snWvUszN6qtvxZn8,37749
5
5
  eodash_catalog/generate_indicators.py,sha256=0IHhu_0yOUoUtLqiTsoYQ2IrTrq00yZme3UE6pC9PIU,19772
6
- eodash_catalog/sh_endpoint.py,sha256=F99LpYT-MGhPiwdSSysm3xBTjaQBXRUkieh-q-vhTvE,1012
6
+ eodash_catalog/sh_endpoint.py,sha256=cDCtyVvZDDY4lQfTpZDHVDM_9sfGrfkVqOOqZoyJYzw,1257
7
7
  eodash_catalog/stac_handling.py,sha256=2iJwBbsBZIBqGWOdnpIfSug0SoOjbkutpSbWAeQRECU,17828
8
8
  eodash_catalog/thumbnails.py,sha256=qZDcpQe80ki6lEMKYdZtSnnHH0PUpcoXTvU9bYdPlzU,2260
9
9
  eodash_catalog/utils.py,sha256=YBB-cfS_Z4ErMAuBVizBQg18IMIxJb4amW1MfDGExg0,11666
10
- eodash_catalog-0.0.34.dist-info/METADATA,sha256=LNzkOJ7Q_si5WMYkWZY0CwDK50Rc5uxqVgp3QpBx3UQ,3196
11
- eodash_catalog-0.0.34.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
12
- eodash_catalog-0.0.34.dist-info/entry_points.txt,sha256=kuUQrDG1PtYd8kPjf5XM6H_NtQd9Ozwl0jjiGtAvZSM,87
13
- eodash_catalog-0.0.34.dist-info/licenses/LICENSE.txt,sha256=oJCW5zQxnFD-J0hGz6Zh5Lkpdk1oAndmWhseTmV224E,1107
14
- eodash_catalog-0.0.34.dist-info/RECORD,,
10
+ eodash_catalog-0.0.36.dist-info/METADATA,sha256=4ljlKb9UOf9HzSQzjKUCeigaeOCKx-LJkry0PlQiccI,3196
11
+ eodash_catalog-0.0.36.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
12
+ eodash_catalog-0.0.36.dist-info/entry_points.txt,sha256=kuUQrDG1PtYd8kPjf5XM6H_NtQd9Ozwl0jjiGtAvZSM,87
13
+ eodash_catalog-0.0.36.dist-info/licenses/LICENSE.txt,sha256=oJCW5zQxnFD-J0hGz6Zh5Lkpdk1oAndmWhseTmV224E,1107
14
+ eodash_catalog-0.0.36.dist-info/RECORD,,