How to authenticate to Icobench.com API with 2 keys in R

JBR Source

I just received a public and private key to connect to ICObench api. I'm quite used to use R, but I admit i found no accurate info on how to authenticate to an API that asks for a public an private key.

Here is their api page telling how to authenticate (though not with R).

I tried the following code (using httr package), which i found on this stackoverflow post :

req <- GET("https://icobench.com/api/v1/icos/ratings",
           authenticate("[email protected]" , "password"),
           add_headers(privateKey = privatekey ),
           add_headers(publicKey = publickey))
stop_for_status(req)
content(req

)

But this code does not seem to work with 2 keys/2 headers. I get the following error message :

"Not provided or missing X-ICObench-Key"

Any idea how to authenticate properly to this API ? There's some nice tutorials for the rest :)

Thanks for your help

rapiauthentication

Answers

answered 8 months ago chinsoon12 #1

You can give the following a try

signature <- openssl::base64_encode(openssl::sha384("", privateKey))

req <- GET("https://icobench.com/api/v1/icos/ratings",
           authenticate("[email protected]" , "password"),
           add_headers("X-ICObench-Sig"=signature),
           add_headers("X-ICObench-Key"=publickey))
stop_for_status(req)
content(req)

comments powered by Disqus