如何使用R中的2个密钥对Icobench.com API进行身份验证

时间:2018-02-13 22:15:53

标签: r api authentication

我刚刚收到一个公钥和私钥来连接到ICObench api。我很习惯使用R,但我承认我没有找到关于如何向API请求公共私钥的准确信息。

Here is their api page告诉如何进行身份验证(尽管不使用R)。

我尝试了以下代码(使用httr包),我在stackoverflow post上找到了:

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

但是这个代码似乎不适用于2个键/ 2个标题。我收到以下错误消息:

"Not provided or missing X-ICObench-Key"

知道如何正确验证此API吗?其余的有一些很好的教程:)

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

您可以尝试以下内容

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

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