Skip to content

Commit

Permalink
throw an error if stac api env variables aren't set, instead of resor…
Browse files Browse the repository at this point in the history
…ting to authentication code flow #213
  • Loading branch information
VincentVerelst committed Nov 29, 2024
1 parent 22c25ba commit 14170ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/worldcereal/openeo/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ def post_job_action_patch(
username = os.getenv("STAC_API_USERNAME")
password = os.getenv("STAC_API_PASSWORD")

if not username or not password:
pipeline_log.warning(
"STAC API credentials not found. Resorting to authorization code flow."
)

stac_api_interaction = StacApiInteraction(
sensor=sensor,
base_url="https://stac.openeo.vito.be",
Expand Down
5 changes: 3 additions & 2 deletions src/worldcereal/stac/stac_api_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pystac_client
import requests
from openeo.rest.auth.oidc import (
OidcAuthCodePkceAuthenticator,
OidcClientInfo,
OidcProviderInfo,
OidcResourceOwnerPasswordAuthenticator,
Expand Down Expand Up @@ -47,7 +46,9 @@ def get_access_token(self) -> str:
client_info=client_info, username=self.username, password=self.password
)
else:
authenticator = OidcAuthCodePkceAuthenticator(client_info=client_info)
raise ValueError(
"Credentials are required to obtain an access token. Please set STAC_API_USERNAME and STAC_API_PASSWORD environment variables."
)

tokens = authenticator.get_tokens()

Expand Down

0 comments on commit 14170ba

Please sign in to comment.