### Get the Token --------------------------------------------------------- # add your Client-ID and Client-Secret from the API Client configuration GUI r <- httr::POST("https://identity.netztransparenz.de/users/connect/token", config = list(), body = list( grant_type = "client_credentials", client_id = Sys.getenv("IPNT_CLIENT_ID"), client_secret = Sys.getenv("IPNT_CLIENT_SECRET") ), encode = "form" ) httr::stop_for_status(r) ### Get the data (Daten) -------------------------------------------------- mydf <- httr::content( httr::GET("https://ds.netztransparenz.de/api/v1/data/prognose/solar/2022-01-01T00%3A00%3A00/2022-01-03T23%3A45%3A00", httr::add_headers("Content-Type" = "application/x-www-form-urlencoded", Accept = "text/plain", "Authorization" = paste("Bearer", httr::content(r)$access_token))), "text", encoding = "UTF-8") mydf <- data.table::fread(mydf)