Hello colleagues,
We are following refinitiv migration [guide](https://developers.lseg.com/en/article-catalog/article/webSocket-api-rto-v2-authentication-migration-guide) and have a trouble to connect to RTO via websockets.
Here is code snippet in python:
import websockets
import json
import asyncio
PING_TIMEOUT = 40
def _make_login_request(auth_token: str) -> dict:
return {
"ID": 1,
"Domain": "Login",
"Key": {
"NameType": "AuthnToken",
"Elements": {
"ApplicationId": "1",
"Position": "127.0.0.1",
"AuthenticationToken": auth_token
}
}
}
async def _consumer(websocket) -> None:
print("Starting messages consumer...")
try:
async for raw_message in websocket:
message_json = json.loads(raw_message)
print(f"<<< incoming {message_json}")
except websockets.exceptions.ConnectionClosed:
print(
"Message consumer stops because websocket disconnected."
)
finally:
print("Messages consumer stopped.")
async def _send_message(websocket, message: dict):
print(f">>> sending {message}")
await websocket.send(json.dumps(message))
async def main() -> None:
endpoint = "us-east-2-aws-3-sm.optimized-pricing-api.refinitiv.net"
port = "443"
token = OUR_SECRET_TOKEN
async with websockets.connect(
f"wss://{endpoint}:{port}/WebSocket",
subprotocols=["tr_json2"],
ping_interval=None,
ping_timeout=PING_TIMEOUT,
) as websocket:
req = _make_login_request(token)
await _send_message(websocket, req)
await _consumer(websocket)
if __name__ == "__main__":
asyncio.run(main())
This method worked perfectly for V1. But now it does not work.
For the token we use Application ID from PAA tool and get error:
[{'ID': 1, 'Type': 'Status', 'Domain': 'Login', 'Key': {'NameType': 5, 'Elements': {'AuthenticationErrorCode': 1026, 'AuthenticationEr
rorText': 'Request for token validation failed:Authentication server did not contain "active" in response'}}, 'State': {'Stream': 'Closed', 'Data':
'Suspect', 'Code': 'UserAccessToAppDenied', 'Text': 'Authentication failed (1026, Request for token validation failed:Authentication server did no
t contain "active" in response).'}}]
Then we tried access token which we obtain with `https://api.refinitiv.com/auth/oauth2/v2/token`. Got this error:
[{'ID': 1, 'Type': 'Status', 'Domain': 'Login', 'Key': {'Name': '<here is token>'}, 'State': {'Stream': 'Closed', 'Data':
'Suspect', 'Code': 'Error', 'Text': 'GE-XXX', unknown to system.'}}]
Where XXX - our service id in the PAA tool. We tried to change ApplicationId to GE-XXX but it did not work.
Please, help us with this problem.
Kind regards.