0

我正在尝试从 Eikon Elektron 云平台获取数据。

我从https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/R/market_price_authentication.R运行以下代码:

library(curl)
> content = paste("grant_type=", "password","&username=", user, "&password=", password, sep="") 
> h <- new_handle(copypostfields = content) 
> h 
<curl handle> (empty) 
> handle_setheaders(h, 
+ "Content-Type" = "application/x-www-form-urlencoded" 
+ ) 
> handle_setopt(h, ssl_verifypeer = FALSE, ssl_verifyhost = FALSE) 
> auth_url = paste("https://", auth_hostname, sep="")# ":", auth_port, "/getToken", sep="") 
> auth_url 
[1] "https://api.refinitiv.com/auth/oauth2/v1/token" 
> req <- curl_fetch_memory(auth_url, **handle = h**) 
> req 
$url 
[1] "https://api.refinitiv.com/auth/oauth2/v1/token" 

$status_code 
[1] 400 

$type 
[1] "application/json" 

**> h 
<curl handle> (https://api.refinitiv.com/auth/oauth2/v1/token)**

> res_headers = parse_headers(req$headers) 
> auth_json_string = rawToChar(req$content) 
> auth_json = fromJSON(auth_json_string) 
> cat(toJSON(auth_json, pretty=TRUE, auto_unbox=TRUE)) 
{ 
"error": "invalid_request" 
}

如您所见,我收到了无效请求错误。我认为问题在于使用curl_fetch_memoryhandle=h相同的输入auth_url,但是它应该使用与 的输入类似的东西content。我可以在我的代码中进行哪些更改以使其正常工作?

4

1 回答 1

0

我找到了如何访问 URL 的解决方案。在 github 中错误地写了 R 文件中的 app_id 应该等于 Reuters 中 App Key 生成器的代码。但是,app_id 和 client_id 是不同的东西,您应该从 App Key 生成器(不是 app_id)中添加 client_id=value。+ 也不要忘记在您的内容中包含 Trapi 等。

于 2020-10-29T14:16:48.497 回答