Closed tvoirand closed 4 years ago
Hi @Bielorusse not all EarthExplorer accounts have permission to download. This privilege must be requested. See the note in the documentation: http://kapadia.github.io/usgs/.
If that's not the issue, I can take a further look.
Thanks for your answer and for pointing out this note in the doc.
I have trouble finding if I have the Machine to Machine access or not and how to request it on the USGS website. I have sent a message with their contact form to find out. On this page my access is displayed as "basic user".
This AUTH_UNAUTHORIZED
error surprises me because I have an account for a few years and I have been downloading Landsat data with another third party library using the API (https://github.com/yannforget/landsatxplore) without any issue.
I will dig a little bit more and let you know if I find anything.
Hi, I finally found some time to have a look again.
I asked the USGS and Landsat help desk to find out if my account has Machine to Machine privilege, but didn't get any answer yet.
I would just like to be sure that I am using the right method with the package, could you please confirm if this is the right way?
from usgs import api
# login
response = api.login("XXX", "XXX")
api_key = response["data"]
# download test product
resp = api.download("LANDSAT_8", "EE", "LC80430012017110LGN00", api_key=api_key)
By the way the login seems to work fine, I am getting the following response:
errorCode None
error
data XXX
api_version 1.4.0
access_level user
catalog_id default
executionTime 0.5516979694366455
@Bielorusse try using the dataset LANDSAT_8_C1
. If you have machine to machine access that request should provide a download url.
resp = api.download("LANDSAT_8_C1", "EE", "LC80430012017110LGN00", api_key=api_key)
Hi @kapadia,
I tried again, I am getting an error both when using the datasat LANDSAT_8_C1
and LANDSAT_8
, sligthly different from before, but which indicates that my account doesn't have the machine to machine privilege.
I have tried using the API directly (both v1.4 and 1.5), and I get the same error.
``` import requests import json # version 1.4 # login r = requests.post( "https://earthexplorer.usgs.gov/inventory/json/v/1.4.0/login", data={ "jsonRequest": json.dumps({"username": "XXX", "password": "XXX"}) }, ) print(r.json()) api_key = r.json()["data"] # download r = requests.post( "https://earthexplorer.usgs.gov/inventory/json/v/1.4.0/download", data={ "jsonRequest": json.dumps( { "datasetName": "LANDSAT_8_C1", "node": "EE", "apiKey": api_key, "entityIds": ["LC80430012017110LGN00"], "products": ["STANDARD"], } ) }, ) print(r.json()) # version 1.5 # login r = requests.post( "https://m2m.cr.usgs.gov/api/api/json/stable/login", json.dumps({"username": "XXX", "password": "XXX"}), ) print(r.json()) api_key = r.json()["data"] # download r = requests.post( "https://m2m.cr.usgs.gov/api/api/json/stable/download-request", json.dumps( { "datasetName": "LANDSAT_8", "node": "EE", "apiKey": api_key, "entityIds": ["LC80430012017110LGN00"], "products": ["STANDARD"], } ), ) print(r.json()) ```
``` {'errorCode': None, 'error': '', 'data': 'XXX', 'api_version': '1.4.0', 'access_level': 'guest', 'catalog_id': 'EE', 'executionTime': 0.6875269412994385} {'errorCode': 'UNKNOWN', 'error': 'AUTH_UNAUTHROIZED: Your account does not have access to this endpoint', 'data': None, 'api_version': '1.4.0', 'access_level': 'user', 'catalog_id': 'EE', 'executionTime': 0.5512990951538086} {'requestId': 17385387, 'version': 'stable', 'data': 'XXX', 'errorCode': None, 'errorMessage': None, 'sessionId': 2115428} {'requestId': 17385399, 'version': 'stable', 'data': None, 'errorCode': 'AUTH_UNAUTHROIZED', 'errorMessage': 'Your account does not have access to this endpoint'} ```
I find this super weird since I am able to download data using scripts via another library (landsatxplore, I'll have to check this other library more deeply to understand what's going on), but it looks like the error is related to my account, so I guess I am going to close this issue.
The good news is I finally found a page to request the machine to machine access on my EROS account (it seems that the EROS account page was updated recently). I have just submitted the request.
Cheers
Hi,
I am getting an error when using the
download
method of the api:Could there be something wrong with my EarthExplorer account?
Many thanks!