Error code 401 | token expired using forward_curves.Definition
Hi, I am running refinitiv python examples on github and can get normal data using rd.open_session(). But when I try to get curves, it fails with Error code 401 | token expired error. Could somebody help? Thanks.
response = forward_curves.Definition(
curve_definition=forward_curves.SwapZcCurveDefinition(
currency="EUR",
index_name="EURIBOR",
discounting_tenor="OIS",
main_constituent_asset_class="Swap",
),
forward_curve_definitions=[
forward_curves.ForwardCurveDefinition(
index_tenor="3M",
forward_curve_tag="ForwardTag",
forward_start_date="2021-02-01",
forward_curve_tenors=["0D", "1D"],
forward_start_tenor="some_start_tenor",
)
],
curve_parameters=forward_curves.SwapZcCurveParameters(valuation_date="2021-02-01"),
curve_tag="some_tag",
).get_data()
response.data.df
Error message:
---------------------------------------------------------------------------RDError Traceback (most recent call last)Cell In[52], line 1----> 1 response = forward_curves.Definition( 2 curve_definition=forward_curves.SwapZcCurveDefinition( 3 currency="EUR", 4 index_name="EURIBOR", 5 discounting_tenor="OIS", 6 main_constituent_asset_class="Swap", 7 ), 8 forward_curve_definitions=[ 9 forward_curves.ForwardCurveDefinition( 10 index_tenor="3M", 11 forward_curve_tag="ForwardTag", 12 forward_start_date="2021-02-01", 13 forward_curve_tenors=["0D", "1D"], 14 forward_start_tenor="some_start_tenor", 15 ) 16 ], 17 curve_parameters=forward_curves.SwapZcCurveParameters(valuation_date="2021-02-01"), 18 curve_tag="some_tag", 19 ).get_data() 21 response.data.dfFile c:\Users\LG\Desktop\test\fennics_test\.venv\lib\site-packages\refinitiv\data\content\_content_provider_layer.py:58, in ContentUsageLoggerMixin.get_data(self, session, on_response)
...
30 error = RDError(error_code, error_message) 32 error.response = response---> 33 raise errorRDError: Error code 401 | token expired
Best Answer
-
Hello @lim_443
I highly recommend you reach out to your LSEG representative to get multiple RDP accounts if you want to run multiple applications/sessions.
If you use a single RDP account with multiple sessions, the applications may encounter an error when an access token expires or when the applications attempt to refresh an access token.
Alternatively, you may set the "signon_control" in the refinitiv-data.config.json to true. This parameter overrides any previous session you logged on i.e. force sign-out this ID from other applications and sign-in here.
{
"logs": {
"level": "debug",
"transports": {
"console": {
"enabled": false
},
"file": {
"enabled": true,
"name": "refinitiv-data-lib.log"
}
}
},
"sessions": {
"default": "platform.rdp",
"platform": {
"rdp": {
"app-key": "App Key",
"username": "RDP Account",
"password": "RDP Password",
"signon_control": true
}
}
}
}0
Answers
-
What session are you using (desktop.workspace or platform.rdp)?
0 -
I am using platform.rdp. Thank you.
0 -
Thank you for the update.
First, please make sure that the RDP account is not used by other users or applications while running the application because there is only one active session for each RDP account.
For example, if the same RDP account is used by another user or application, the previous session will be invalidated and the previous application can't renew the token.
You can enable logging in the library to verify what the problem is by using the following code.
config = rd.get_config()
config.set_param("logs.transports.file.enabled", True)
config.set_param("logs.transports.file.name", "refinitiv-data-lib.log")
config.set_param("logs.level", "debug")
rd.open_session("platform.rdp")Then, please share the refinitiv-data-lib.log file when the problem occured. Please also remove the RDP credentials in the log file.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛