0
我使用httr
來查詢Open Targets API。如何使用httr請求API令牌?
我收到了我的API憑證(APP_NAME和密碼),現在我想通過嘗試對Python的翻譯提供指導索取令牌:
import requests
API='https://www.targetvalidation.org/api/latest/'
jwt = requests.get(API + 'public/auth/request_token',
params={'app_name':<appname>,'secret':<secret>})
print(jwt.json())
這就是我試圖用R和HTTR:
library(httr)
app_name <- "myappname"
secret <- "mysecret"
token <-
GET("https://www.targetvalidation.org/api/latest/public/auth/request_token", app_name = app_name, secret = secret)
token <- GET("https://www.targetvalidation.org/api/latest/public/auth/request_token", add_headers(app_name = app_name, secret = secret))
token <- GET("https://www.targetvalidation.org/api/latest/public/auth/request_token", config = list(app_name = app_name, secret = secret))
# In all cases, this is what I get
token
# Response [https://www.targetvalidation.org/api/latest/public/auth/request_token]
# Date: 2017-04-24 08:24
# Status: 400
# Content-Type: application/json
# Size: 60 B
# {"message": {"app_name": "app name [appname] is required"}}
什麼是正確的語法httr
要求該令牌?
謝謝!