Skip to content

Commit b691b6d

Browse files
authored
FIX: One last missing token parameter. (#1035)
1 parent 54030c0 commit b691b6d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

act/discovery/neon.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_neon_product_avail(token, site_code, product_code, print_to_screen=False
105105
return dates
106106

107107

108-
def download_neon_data(site_code, product_code, start_date, end_date=None, output_dir=None):
108+
def download_neon_data(token, site_code, product_code, start_date, end_date=None, output_dir=None):
109109
"""
110110
Returns a list of data products available for a NEON site. Please be sure to view the
111111
readme files that are downloaded as well as there may be a number of different products.
@@ -121,6 +121,8 @@ def download_neon_data(site_code, product_code, start_date, end_date=None, outpu
121121
122122
Parameters
123123
----------
124+
token : str
125+
The access token for the NEON API web server.
124126
site : str
125127
NEON site identifier. Required variable
126128
product_code : str
@@ -144,6 +146,9 @@ def download_neon_data(site_code, product_code, start_date, end_date=None, outpu
144146
# Every request begins with the server's URL
145147
server = 'http://data.neonscience.org/api/v0/'
146148

149+
# Add token to headers
150+
headers = {"X-API-TOKEN": token}
151+
147152
# Get dates to pass in
148153
if end_date is not None:
149154
date_range = pd.date_range(start_date, end_date, freq='MS').strftime('%Y-%m').tolist()
@@ -154,7 +159,9 @@ def download_neon_data(site_code, product_code, start_date, end_date=None, outpu
154159
files = []
155160
for date in date_range:
156161
# Make Request
157-
data_request = requests.get(server + 'data/' + product_code + '/' + site_code + '/' + date)
162+
data_request = requests.get(
163+
server + 'data/' + product_code + '/' + site_code + '/' + date, headers=headers
164+
)
158165
data_json = data_request.json()
159166

160167
if output_dir is None:

0 commit comments

Comments
 (0)