MrChebur / usgs-machine-to-machine-API

Simple Python wrapper of the USGS/EROS Inventory Service Machine-to-Machine API as described in the documents at https://m2m.cr.usgs.gov/api/docs/json/
GNU General Public License v3.0
18 stars 7 forks source link

Python vs R USGS access to API #6

Closed henrykironde closed 2 years ago

henrykironde commented 2 years ago

I know this may not be the right place for this, but are there restrictions to the programing language used to interact with the API?

For example in R, this could be the same as

psw ="usgs-pass.json" # provide path to the file with password and username
library(jsonlite)
library(httr)

api <- list(
  'apiURL' = paste0('https://m2m.cr.usgs.gov/api/api/json/stable/'), 
  'apiKey' = NULL,
  'loud_mode' = FALSE
)

jsonData = fromJSON(psw) 
password <- as.matrix(jsonData$password)
username <- as.matrix(jsonData$username)
urln = paste0(api$apiURL, "login")
userContext= NULL

params <- list('username' = username,
               'password' = password,
               'userContext' = userContext)

# res <- POST(urln, authenticate(username, password))
res <- POST(urln, body = params, encode = "json", user_agent("httr"))
# res <- POST(urln, body = params)
v <- content(res)$data

We are trying to revive usgs_login https://github.com/16EAGLE/getSpatialData, any help is much appreciated.

MrChebur commented 2 years ago

There are no such restrictions, or I don't know anything about them.