Skip to content

Commit

Permalink
earthaccess.get_s3_credentials can use the results to get the S3 cred…
Browse files Browse the repository at this point in the history
…entials
  • Loading branch information
betolink committed Sep 13, 2023
1 parent a85f531 commit ca6590f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions earthaccess/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,29 @@ def open(


def get_s3_credentials(
daac: Optional[str] = None, provider: Optional[str] = None
daac: Optional[str] = None,
provider: Optional[str] = None,
results: Optional[list[earthaccess.results.DataGranule]] = None,
) -> Dict[str, Any]:
"""Returns temporary (1 hour) credentials for direct access to NASA S3 buckets
"""Returns temporary (1 hour) credentials for direct access to NASA S3 buckets, we can
use the daac name, the provider or a list of results from earthaccess.search_data()
if we use results earthaccess will use the metadata on the response to get the credentials,
this is useful for missions that do not use the same endpoint as their DAACs e.g. SWOT
Parameters:
daac: a DAAC short_name like NSIDC or PODAAC etc
provider: if we know the provider for the DAAC e.g. POCLOUD, LPCLOUD etc.
daac (String): a DAAC short_name like NSIDC or PODAAC etc
provider (String: if we know the provider for the DAAC e.g. POCLOUD, LPCLOUD etc.
results (list[earthaccess.results.DataGranule]): List of results from search_data()
Returns:
a dictionary with S3 credentials for the DAAC or provider
"""
if daac is not None:
daac = daac.upper()
if provider is not None:
provider = provider.upper()
if results is not None:
endpoint = results[0].get_s3_credentials_endpoint()
return earthaccess.__auth__.get_s3_credentials(endpoint=endpoint)
return earthaccess.__auth__.get_s3_credentials(daac=daac, provider=provider)


Expand Down

0 comments on commit ca6590f

Please sign in to comment.