question

Upvotes
Accepted
39 3 3 7

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



datastream-api
icon clock
10 |1500

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

Upvotes
Accepted
39 3 3 7

Hi,

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

Thanks for the supports anyway.

TH

icon clock
10 |1500

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

Upvotes
79.2k 251 52 74

@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.


1696820371924.png (36.5 KiB)
1696820476652.png (25.7 KiB)
icon clock
10 |1500

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

Upvotes
39 3 3 7

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.


icon clock
10 |1500

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

Upvotes
79.2k 251 52 74

@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.


1696911058806.png (47.8 KiB)
icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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