DatastreamDSWS Invaliad Token Error

Hello,

Today I tried ds.get_data() from DatastreamDSWS package and got the following error:

ds.get_data(tickers='VOD', fields='P', kind=0)

get_data : Exception Occured
(<class 'Exception'>, Exception('Invalid Token Value'), <traceback object at 0x7fd834d87fc0>)
None

Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/DatastreamPy/DS_Response.py", line 148, in get_data
raise Exception("Invalid Token Value")
Exception: Invalid Token Value

Would appreciate any help to fix this error.

Thanks,

TH



Tagged:

Best Answer

  • tta
    tta
    Answer ✓

    Hi,

    It is so weird that the same query just works today without any changes!

    Thanks for the supports anyway.

    TH

Answers

  • @tta

    Thank you for reaching out to us.

    The DSWS credentials may be incorrect.

    You can check the DSWS credentials by accessing the DSWS Test REST Service website.

    1696820371924.png

    Select the Get Token service method, enter DSWS username and password, and then click on the Execute button.

    If the credentails are vaild, you will get a token in the response.

    1696820476652.png

    If you are unable to get a token, please contact your Refinitiv account team or sales team directly to verify what the problem is.

  • Hi,

    I was able to get a token:

    "Properties": null,
    "TokenExpiry": "2023-10-10T20:31:01",
    "TokenValue": "ttYLEuYH..."

    Yet, I still got that error exception in. However, if I execute the same query in the Codebook environment (built-in Workspace) with my credentials, it works perfectly.


  • @tta

    The error is obvious that the token is invalid.

    You may enable debugging in Python to verify the retrieved response by using the following code.

    import logging
    import http.client 
    http.client.HTTPConnection.debuglevel = 1 
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True

    You should see this:

    1696911058806.png

    If you would like to share the response, please remove the credentials before sharing.