401 Authentication Issue, Connecting to NLDAS with R's GET
Posted: Thu Jan 30, 2025 1:28 pm America/New_York
Hi,
I'm attempting to connect to the NLDAS Forcing dataset via GrADS server ASCII calls, generated in R and called through R's GET() function via the HTTR package. I've generated a series of URLs that seem to work when pasted into my browser (with username/password authentication via prompt), however when I try to pull the data in R, I run into a Status 401, Access Denied error. Any advice on authentication via R would be appreciated, as I've used GET with user/password authorization in the past with no issues (see method 1). I've tried a couple different ways, including specifying my token in the header (token generated today); see examples below:
url <- "https://hydro1.gesdisc.eosdis.nasa.gov/dods/NLDAS_FORA0125_H.2.0.ascii?wind_e[271739:276739][33][354]"
Method 1: GET(url, authenticate(key_get("nldas-credential-user"), key_get("nldas-credential-pass")))
Method 2: GET(url, authenticate(key_get("nldas-credential-user"), key_get("nldas-credential-pass")), add_headers(paste("Authorization: Bearer", my-token)))
Relevant Information:
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.2
Packages:
keyring_1.3.2
jsonlite_1.8.9
httr_1.4.7
curl_6.1.0
I'm attempting to connect to the NLDAS Forcing dataset via GrADS server ASCII calls, generated in R and called through R's GET() function via the HTTR package. I've generated a series of URLs that seem to work when pasted into my browser (with username/password authentication via prompt), however when I try to pull the data in R, I run into a Status 401, Access Denied error. Any advice on authentication via R would be appreciated, as I've used GET with user/password authorization in the past with no issues (see method 1). I've tried a couple different ways, including specifying my token in the header (token generated today); see examples below:
url <- "https://hydro1.gesdisc.eosdis.nasa.gov/dods/NLDAS_FORA0125_H.2.0.ascii?wind_e[271739:276739][33][354]"
Method 1: GET(url, authenticate(key_get("nldas-credential-user"), key_get("nldas-credential-pass")))
Method 2: GET(url, authenticate(key_get("nldas-credential-user"), key_get("nldas-credential-pass")), add_headers(paste("Authorization: Bearer", my-token)))
Relevant Information:
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.2
Packages:
keyring_1.3.2
jsonlite_1.8.9
httr_1.4.7
curl_6.1.0