Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Refinitiv Data Platform /
  • Refinitiv Data Platform Libraries /
avatar image
Question by JIAN.DU · Jul 15, 2020 at 01:09 PM · pythonrdp-apirefinitiv-data-platformrefinitiv-data-platform-libraries

RDP python library not raising exception on invalid_token

Hi

I am currently using RDP python package 1.0.0.a0

Currently the library allows checking the session state using rdp.session.get_open_state, but if the underlying token becomes invalid, the library currently does not raise an exception.

We are running some code on server A. Today, the same account was used to log into server B. This meant that that server A was no longer authenticated with Refinitiv, even though there was an open session state.

Using rdp.session_get_open_state, server A still had an open session, however from the logs refinitiv servers returned an invalid_token request on server A.

Should an error be raised when server returns invalid token? Or is there a way to check or send a heartbeat to the server to check whether the token is still valid, before a data request is sent?

rdp.HistoricalPricing.get_summaries(...)
2020-07-15 12:30:35,044 - hpack.hpack - DEBUG - Decoded (b'www-authenticate', b'Bearer realm="GET /data/historical-pricing/v1/views/events/{universe}", scope="trapi.data.historical-pricing.events.read", error="invalid_token", error_description="token expired"'), total consumed 149 bytes, indexed False

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

3 Replies

  • Sort: 
avatar image
Best Answer
Answer by JIAN.DU · Jul 15, 2020 at 08:45 PM

Hi Nick.

It turns out, my other asyncio loop was conflicting with the one in platform_session.py (I am on 1.0.0a0).

Because of this conflict, I was not able to get any values when calling PlatformSession.get_last_event_code() and PlatformSession.get_last_event_message() were returning 'None'.

I think, rdp library platform_session.py should be changed from:

def run(self):
    self._loop = asyncio.new_event_loop()
    asyncio.set_event_loop(self._loop)

To

def run(self):
    try:
        self._loop = asyncio.get_event_loop()
    except RuntimeError:
        self._loop = asyncio.new_event_loop()

This way, when I call PlatformSession.get_last_event_code() and PlatformSession.get_last_event_message(), they return valid values related to the token/session:

EventCode.SessionAuthenticationFailed
iPlanet session has been expired.

I am by no means an asyncio expert, is this something you could raise with the developers? I could not find a github repository for the rdp library to raise this issue.

Thanks

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by umer.nalla · Jul 15, 2020 at 01:25 PM

Hi @JIAN.DU

Can you confirm if you are using the session state event handlers e.g.

rdp.PlatformSession(
    app_key,
    rdp.GrantPassword(
    username = user,
    password = password),
    on_state = lambda session, state, message : print("Platform session state: ", state, message),
    on_event = lambda session, event, message : print("Platform session event: ", event, message))

The same can be done for Eikon/desktop and TREP sessions as well.

Also, my colleague will do some test around authentication with the latest version of RDP library and respond once completed.

Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
JIAN.DU · Jul 15, 2020 at 02:32 PM 0
Share

Hi Umer - I have set on_state and on_event yes, but it doesn't not trigger, I believe. I am checking the state manually.

avatar image
REFINITIV
Answer by nick.zincone · Jul 15, 2020 at 05:14 PM

Hi @JIAN.DU,

The behavior I would expect you should get is that on A, when the application attempts to refresh its access token, a session authentication event should be raised within the Session indicating an issue. In this scenario, did you mistakenly start an application on server B? Or did you want the application on server B to assume control of authentication? Or did you expect the application on server A to steal it back?

Comment

People who like this

0 Show 4 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
JIAN.DU · Jul 15, 2020 at 05:42 PM 0
Share

Hi Nick - yes that's right. It was launched by mistake. I am looking to code in so that if it happens again, to check the token and refresh the session (steal it back explicitly) on exception. I do not expect the library to do this by default.

rdp.PlatformSession.get_open_state() was returning Session.State.Open even though it had lost the token and could not request.

I guess ideally if there was a way to also check the status of the token itself?

I have the on_event and on_state enabled as per Umer above however I do not see the lambda being called when I tried to replicate losing the token. (Could very well be my mistake)

avatar image
REFINITIV
nick.zincone ♦♦ JIAN.DU · Jul 15, 2020 at 06:08 PM 0
Share

Hi @JIAN.DU,

I will notify the Python team regarding your findings.

Just so you are aware, if you do code around this issue you will need to ensure it occurs during a refresh (not startup). Also, if you happen to run the same application on server B (as you mistakenly did), both the instances will, in effect, be "stealing" the token from each other during there respective refresh cycle.

avatar image
REFINITIV
nick.zincone ♦♦ nick.zincone ♦♦ · Jul 16, 2020 at 02:00 AM 0
Share

Thanks @JIAN.DU,

Just to clarify, after you discovered your conflicting asyncio loop, did you receive the expected events when the refresh failed?

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
9 People are following this question.

Related Questions

issue to use refinitiv_dataplatform with python

Python RDP API does not use proxy server when connecting

RDP authentication error

Get ETF Holdings using RDP Python Library

Asynio library errors when running rdp.StreamingPrices simple test

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges