Declaration of API key in Rstudio

Hello!

I am having issues to get data from an API within RStudio.

I am declaring the API key in the environment via Sys.setenv, then calling GET and getting the following error: Error in curl::curl_fetch_memory(url, handle = handle) :
schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - The token supplied to the function is invalid

When trying in the browser, the query and the key work perfectly.

R code:
library(httr)
library(jsonlite)
library(curl)
set_config(use_proxy(url = "mycompanyproxy", username = "XX", password = "XX"))

Sys.setenv(TIINGO_TOKEN = "myapikey")

data <- httr::GET("https://api.datalastic.com/api/v0/vessel_history",
httr::add_headers(Authorization="TIINGO_TOKEN"),
query = list("imo" = 9925253,"from"="2024-06-01","to"="2024-07-01")
)

THANKS FOR THE HELP!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.