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

  • wasin.w
    wasin.w admin
    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
                }
            }
        }
    }

Answers

  • @lim_443

    What session are you using (desktop.workspace or platform.rdp)?

  • I am using platform.rdp. Thank you.

  • Hi @lim_443 ,


    I have checked the query on my end and it returns the data, so no issues with the code. Would you mind retrying on a different environment, also would be good to run the code in Codebook as well and see if that returns the data?


    Best regards,

    Haykaz

  • @lim_443

    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.