Giter Site home page Giter Site logo

rte.data's People

Contributors

cderv avatar pvictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rte.data's Issues

process data prevents unavalaible generators from working

Bonjour,
J'ai voulu requêter digital.iservices.rte-france.com/open_api/unavailability_additional_information/v1/generation_unavailabilities mais le merge qui est dans le process data engendre une erreur.
Cordialement
Aurélien

Issue with token base64 encoding

There is an issue with token obtention because a \n is added in base64 encoded string with jsonlite. And strangely, this is not handle by the API. This \n addition is on purpose as explained in jeroen/jsonlite#220

Would it be possible to use base64enc or openssl ?

# dummy ids
id_client <- "bcfe5cb5-89ac-4etb-ba60-2f83015c3e78"
id_secret <- "62ade741-453b-4d20-a812-ad1e0aad63ae"
key = list(id_client = id_client, id_secret = id_secret)
raw_string <- charToRaw(paste(key$id_client, key$id_secret, sep = ":"))
jsonlite::base64_enc(raw_string)
#> [1] "YmNmZTVjYjUtODlhYy00ZXRiLWJhNjAtMmY4MzAxNWMzZTc4OjYyYWRlNzQxLTQ1M2ItNGQy\nMC1hODEyLWFkMWUwYWFkNjNhZQ=="
base64enc::base64encode(raw_string)
#> [1] "YmNmZTVjYjUtODlhYy00ZXRiLWJhNjAtMmY4MzAxNWMzZTc4OjYyYWRlNzQxLTQ1M2ItNGQyMC1hODEyLWFkMWUwYWFkNjNhZQ=="
openssl::base64_encode(raw_string)
#> [1] "YmNmZTVjYjUtODlhYy00ZXRiLWJhNjAtMmY4MzAxNWMzZTc4OjYyYWRlNzQxLTQ1M2ItNGQyMC1hODEyLWFkMWUwYWFkNjNhZQ=="

Created on 2019-06-13 by the reprex package (v0.3.0.9000)

key = list(id_client = id_client, id_secret = id_secret)
rte.data::get_token(key)
#> Error: Bad Request (HTTP 400)

get_token2 <- function(key, user = NULL, proxy_pwd = NULL) {
  if (is.list(key))
    key <- base64enc::base64encode(charToRaw(paste(key$id_client, key$id_secret, sep = ":")))
  cli <- crul::HttpClient$new(
    url = rte.data:::get_url("url.auth"),
    headers = list(
      Authorization = paste("Basic", key)
    )
  )
  res <- try(cli$post(), silent = TRUE)
  if ("try-error" %in% class(res))
    stop(proxy_error(getOption("rte.data.url.base")))
  res$raise_for_status()
  txt <- res$parse("UTF-8")
  json <- jsonlite::fromJSON(txt)
  json
}
res <- get_token2(key)
names(res)
#> [1] "access_token" "token_type"   "expires_in"

Created on 2019-06-13 by the reprex package (v0.3.0.9000)

Question about token management

Why the choice of storing a token by api name ?

With data.rte-france.com, you can create an application that can register several api ressource and with the same id client and secret (so same token), you can retrieve several ressource.

Currently, if I use set_key and I need to register once for get_consumption, and once for get_physical_flows. However, I register the two ressource in the same app, so one token can get me both.

Does your package suppose that one resource is register in one application ?

I think a mechanism closer to the one in httr with a logic of registering an application to get access to some resources can help avoid duplication in options or environment variables.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.