lucadelu / pyModis

python library to work with MODIS data
http://www.pymodis.org/
Other
165 stars 85 forks source link

MODIS authorization stopped working #149

Closed anton-petrov closed 1 year ago

anton-petrov commented 2 years ago

Recently, systems were updated to require a token for login instead of credentials (from NASA forum). Login and password authorization stopped working on NASA servers. Instead of that introduced a bearer token authorization mechanism. This PR closes this issue.

MarcoHannemann commented 2 years ago

Thanks for your work, I thought the problems were still related to the maintenance the servers experienced. Is there any documentation on how to use pyModis with that token? I tried your code with use of Login/password, but getting an Error logged in the logfile, I guess it may be related to the authorization mechanism?

2022-08-16 14:03:57,720 - ERROR - Error <urlopen error _ssl.c:1114: The handshake operation timed out> when try to receive list of files
2022-08-16 14:03:57,725 - DEBUG - Starting new HTTPS connection (1): e4ftl01.cr.usgs.gov:443
anton-petrov commented 2 years ago

Please, use my updated PR, I just made small improvement. Also, you need to incease timeout from default 30 secs to 120 secs (in my case it helped) and it related not to authorization but to the huge load of the NASA servers.

example for token:

modisDown = downModis(destinationFolder=tmp_cached, 
                      token=token, 
                      product=product,
                      tiles=tile_id, 
                      today=date, 
                      debug=True, 
                      timeout=120, 
                      delta=1)

example for login/password:

modisDown = downModis(destinationFolder=tmp_cached, 
                      user=login,
                      password=password,
                      product=product,
                      tiles=tile_id,
                      today=date,
                      debug=True,
                      timeout=120,
                      delta=1)
anton-petrov commented 2 years ago

By the way, you need to open your profile page at https://urs.earthdata.nasa.gov/profile and click Generate Token to be able to use it.

geoschen commented 2 years ago

the downmodis.py not need update?

anton-petrov commented 2 years ago

the downmodis.py not need update?

Please, look at PR https://github.com/lucadelu/pyModis/pull/148/files
Yes, downmodis.py has been changed. You may just copy-paste changed file.

geoschen commented 2 years ago

l can't connection 2022-08-19 10:15:40,387 - ERROR - Error in connection. Code 404, reason Not Found

from pymodis import downmodis d_tiles = {'anH': 'h27v05, h28v05, h28v06', 'aoM': "h28v06", 'beiJ': "h26v04, h27v04, h26v05, h27v05", 'fuJ': "h28v06", 'ganS': "h25v04, h25v05, h26v05", 'guangD': "h28v06, h28v07", 'guangX': "h27v06, h28v06", 'guiZ': "h27v06", 'haiN': "h28v06, h28v07", 'heB': "h26v04, h27v04, h26v05, h27v05", 'heN': "h27v05", 'heiLJ': "h25v03, h26v03, h26v04, h27v04", 'huB': "h27v05, h28v05, h27v06, h28v06", 'huN': "h27v05, h27v06, h28v06", 'jiL': "h26v04, h27v04", 'jiangS': "h27v05, h28v05", 'jiangX': "h28v06, h28v05, h27v06", 'liaoN': "h26v04, h27v04, h27v05", 'neiMG': "h25v03, h26v03, h25v04, h26v04, h27v04, h25v05, h26v05", 'ningX': "h26v05", 'qingH': "h25v05, h26v05", 'shanD': "h27v05", 'shanX': "h26v05, h27v05, h26v04", 'shannX': "h26v05, h27v05", 'shangH': "h28v05", 'siC': "h26v05, h27v05, h26v06, h27v06", 'taiW': "h28v06, h29v06", 'tianJ': "h26v04, h27v04, h26v05, h27v05", 'xiZ': "h24v05, h25v05, h26v05, h25v06, h26v06", 'xiangG': "h28v06", 'xinJ': "h23v04, h24v04, h25v04, h23v05, h24v05, h25v05", 'yunN': "h26v06, h27v06", 'zheJ': "h28v05, h28v06", 'chongQ': "h27v05, h27v06"}

products={ 'LST':'MOD11A1.O61', # daytime 1000km 'ndvi&evi':'MYD13A1.006' # 500m

}

dest=r'D:\modis' tiles = d_tiles['anH'] product=products['LST'] delta = 1460 startday = '2010-05-01' endday='2010-01-01' username='...' password='...' token='' modisDown =downmodis.downModis(destinationFolder=dest,user=username,password=password, token=token, product=product, tiles=tiles, today=startday, enddate=endday, debug=True, timeout=120, delta=delta) modisDown.connect() modisDown.downloadsAllDay()

MarcoHannemann commented 2 years ago

@geoschen

l can't connection 2022-08-19 10:15:40,387 - ERROR - Error in connection. Code 404, reason Not Found

I guess this error is not connected to the authorization issue.

At first glance it looks like you may have a typo here - I guess it should be 'MOD11A1.061'

products={
'LST':'MOD11A1.O61', # daytime 1000km
'ndvi&evi':'MYD13A1.006' # 500m

}

If you feel your problem is caused by pymodis, I would recommend to raise a separate issue describing your problem. Also please look into how to format code properly.

You may want to edit your answer and remove your personal token from your code, since it is personal and not intended for the public.

geoschen commented 2 years ago

@geoschen

l 无法连接 2022-08-19 10:15:40,387 - 错误 - 连接错误。代码 404,未找到原因

我猜这个错误与授权问题无关。

乍一看,您可能在这里打错字了——我猜应该是“MOD11A1”。0 61'

products={
'LST':'MOD11A1.O61', # daytime 1000km
'ndvi&evi':'MYD13A1.006' # 500m

}

如果您觉得您的问题是由 pymodis 引起的,我建议您提出一个单独的问题来描述您的问题。另请查看如何正确格式化代码。

您可能想要编辑您的答案并从您的代码中删除您的个人令牌,因为它是个人的,不适合公众使用。 thanks

anton-petrov commented 2 years ago

@lucadelu your participation is required

lucadelu commented 2 years ago

new release was just done, please close the ticket if it works