Skip to content

consider move to {earthdatalogin}, (or httr2 and bearer_token) for authorization #275

@mdsumner

Description

@mdsumner

In #257 there are various reports of failure to authenticate even with valid user/pass, that is also my experience. (I'm considering maintaining this package, but be aware it will involve quite a bit of change and the scope of that is unknown as yet).

EDIT: oh I had lost sight of the changes here, I will take that on board: #273

What did work for me, was the get the token and use httr2 auth bearer:

token <- "<long string of characters *without* Authorization: Bearer prefix>"
library(httr2)
## inserting changes to code that are at line 75 in MODIStsp_download.R
remote_filename <- "https://e4ftl01.cr.usgs.gov/MOLT/MOD13A2.061/2016.06.09/MOD13A2.A2016161.h18v04.061.2021353012725.hdf"
r <- request(paste0(remote_filename, ".xml"))
rp <- req_auth_bearer_token(r, gsub("Authorization: Bearer ", "", token))
 req_perform(rp)
<httr2_response>
GET https://e4ftl01.cr.usgs.gov/MOLT/MOD13A2.061/2016.06.09/MOD13A2.A2016161.h18v04.061.2021353012725.hdf.xml
Status: 200 OK
Content-Type: application/xml
Body: In memory (18359 bytes)

it will be a bit of work to apply this (and I'd like to figure out why user/pass isn't working, it certainly is for me for generic download with wget etc), so interested in any futher feedback.

The Authorization/Bearer mechanism of earthdata is well supported now and understood, so we should leverage {earthdatalogin} I think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues due to a code bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions