Skip to content

Commit

Permalink
Add environment auth option
Browse files Browse the repository at this point in the history
  • Loading branch information
eculler committed Apr 24, 2024
1 parent f9db8be commit 20e0b17
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions earthpy/appeears.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import os
import pathlib
import re
import requests
import time
from glob import glob

import keyring
import requests

class AppeearsDownloader(object):
"""
Expand Down Expand Up @@ -174,6 +174,14 @@ def login(self, service='NASA_EARTHDATA', username_id='NED_USERNAME'):
except:
username = None
password = None

# Get username and password from environment
try:
username = os.environ['EARTHDATA_USERNAME']
password = os.environ['EARTHDATA_PASSWORD']
except:
username = None
password = None

# Prompt user if no username or password is stored
if (username is None) or (password is None):
Expand Down Expand Up @@ -337,4 +345,4 @@ def download_files(self, cache=True):
f.write(data)

# Remove task id file when download is complete
os.remove(self.task_id_path)
os.remove(self.task_id_path)

0 comments on commit 20e0b17

Please sign in to comment.