401 Authentication Issue, Connecting to NLDAS with R's GET

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
rishi.kowalski
Posts: 5
Joined: Thu Jan 30, 2025 12:24 pm America/New_York
Answers: 0

401 Authentication Issue, Connecting to NLDAS with R's GET

by rishi.kowalski » 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

Filters:

GES DISC - jimacker
User Services
User Services
Posts: 19
Joined: Wed Dec 04, 2024 4:05 pm America/New_York
Answers: 0
Been thanked: 1 time

Re: 401 Authentication Issue, Connecting to NLDAS with R's GET

by GES DISC - jimacker » Tue Feb 04, 2025 11:33 am America/New_York

Hello, I apologize for our slow response. We are examining your query now.

rishi.kowalski
Posts: 5
Joined: Thu Jan 30, 2025 12:24 pm America/New_York
Answers: 0

Re: 401 Authentication Issue, Connecting to NLDAS with R's GET

by rishi.kowalski » Tue Feb 04, 2025 11:51 am America/New_York

Hi,

Thanks for the reply - I actually ended up resolving this issue by following the instructions here to associate my .netrc file with the query (https://urs.earthdata.nasa.gov/documentation/for_users/data_access/r) and my queries are working now. I'm not sure how or why they were working previously without the .netrc file however!

Thanks again!

GES DISC - jimacker
User Services
User Services
Posts: 19
Joined: Wed Dec 04, 2024 4:05 pm America/New_York
Answers: 0
Been thanked: 1 time

Re: 401 Authentication Issue, Connecting to NLDAS with R's GET

by GES DISC - jimacker » Tue Feb 04, 2025 2:57 pm America/New_York

Excellent. I am glad that the instructions were both useful and correct.

Post Reply