Hello, I am struggling in setting my global environment variables to get data via websocket in Elektron.
I tried Python code and it works fine, the connection gives access_token. However, using these variables in R does not give this token. Files can be downloaded here https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api/download
For python I got following settings (market authentication file):
# Global Default Variables
app_id = '256'
auth_url = 'https://api.refinitiv.com:443/auth/oauth2/v1/token';
hostname = 'emea-1.pricing.streaming.edp.thomsonreuters.com'
password = 'MY PASSWORD WHEN SETTING MACHINE ID'
newPassword = ''
position = ''
sts_token = ''
refresh_token = ''
user = 'MACHINE ID'
clientid = 'APP ID VIA APPKEY GENERATOR'
port = '443'
client_secret = ''
scope = 'trapi'
ric = '/TRI.N'
service = 'ELEKTRON_DD'
Here I got an output:
Sending authentication request with password to https://api.refinitiv.com:443/auth/oauth2/v1/token ...
Refinitiv Data Platform Authentication succeeded. RECEIVED:
{
"access_token":"",
"expires_in":"300",
"refresh_token":"b92019b7-914c-4dc9-b5a9-b504ae3f99ec",
"scope":"trapi.auth.cloud-credentials trapi.cfs.claimcheck.read trapi.data.symbology.advanced.read trapi.data.symbology.read trapi.metadata.read trapi.streaming.pricing.read",
"token_type":"Bearer"
}
In R I set following (in auth_hostname i deleted https://, because in R code it will add this):
# Global Default Variables
hostname = "emea-1.pricing.streaming.edp.thomsonreuters.com"
port = "443"
user = "MACHINE ID"
app_id = "APP ID VIA APPKEY GENERATOR"
auth_token = ""
auth_hostname = "api.refinitiv.com:443/auth/oauth2/v1/token"
auth_port = "443"
password = "MY PASSWORD WHEN SETTING MACHINE ID"
However, in R when running code, it shows following:
> auth_url
[1] "https://api.refinitiv.com:443/auth/oauth2/v1/token"
> req
$url
[1] "https://api.refinitiv.com:443/auth/oauth2/v1/token"
$status_code
[1] 400
$type
[1] "application/json"
Can you help in setting up my variables for R? additionally I noticed that in R market_price file there is a need to set only following variables. Here no need to set the password. How can it be possible?
hostname = "emea-1.pricing.streaming.edp.thomsonreuters.com"
port = "443"
user = "MACHINE ID "
app_id = "APP ID VIA APPKEY GENERATOR"
UPDATE: 28.10.2020 14:22 CET
I figured out that in R should be following:
hostname = "emea-1.pricing.streaming.edp.thomsonreuters.com"
port = "443"
auth_hostname = "api.refinitiv.com:443/auth/oauth2/v1/token"
auth_port = "443"
However I have following error. I found that in Python code grand_types="password". I tried in R grand_types equals to the word password as a string and as a character from password(=password) and the same error persisted. How can I tackle it?
> cat(toJSON(auth_json, pretty=TRUE, auto_unbox=TRUE))
{
"error": {
"id": "46309bba-637b-47a3-9d7a-ba8d931cb063",
"code": "400",
"message": "Validation error",
"status": "Bad Request",
"errors": [
{
"key": "grant_type",
"reason": "Missing required parameter 'grant_type'"
}
]
}