Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add us-west-2 check to API and improve auth repr #424

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Next Next commit
add auth_info property
  • Loading branch information
JessicaS11 committed Jan 8, 2024
commit 228972f33d1323a86191fc207940a4a0005b35fc
29 changes: 28 additions & 1 deletion earthaccess/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ def __init__(self) -> None:
self.EDL_GENERATE_TOKENS_URL = "https://urs.earthdata.nasa.gov/api/users/token"
self.EDL_REVOKE_TOKEN = "https://urs.earthdata.nasa.gov/api/users/revoke_token"

def __str__(self) -> str:
print_str = "Authentication Info\n" + "----------\n"
for k, v in self.auth_info:
print_str += str("{}: {}\n".format(k, v))

return print_str

@property
def auth_info(self) -> Dict:
"""Get information about the authentication session

Returns:
Dict: information about the auth object
"""
summary_dict: Dict[str, Any]
summary_dict = {
"authenticated?": self.authenticated,
"tokens": self.tokens,
}

#modify this to get the region check if in s3
# add a separate in uswest2 access point to api?
if "Region" in self.s3_bucket():
summary_dict["cloud-info"] = self.s3_bucket()

return summary_dict

def login(self, strategy: str = "netrc", persist: bool = False) -> Any:
"""Authenticate with Earthdata login

Expand Down Expand Up @@ -154,7 +181,7 @@ def get_s3_credentials(
daac: the name of a NASA DAAC, i.e. NSIDC or PODAAC
endpoint: getting the credentials directly from the S3Credentials URL

Rreturns:
Returns:
A Python dictionary with the temporary AWS S3 credentials

"""
Expand Down