invalid token error when using content summaries, but not get_history, using lseg.data API

davidk
davidk Contributor

I'm not sure what I may be doing wrong here. When I use the LSEG Data Library to download historical interday data, if I do the request like this, it gives back data just fine:

In [165]: ld.get_history('MSFT.O', 'TR.Volume', interval='1D', start='2025-01-01', end='2025-06-06')

Out[165]:
MSFT.O Volume
Date
2025-01-02 16896469
2025-01-03 16662943
2025-01-06 20573648
2025-01-07 18139065
2025-01-08 15054575


However, if I instead spell the query using the content API, using:

definition = ld.content.historical_pricing.summaries.Definition('MSFT.O', fields=['TR.Volume'], start='2025-01-01', end='2025-06-06', interval='P1D')
definition.get_data()

I get a 403 forbidden error saying I have an invalid token:

```
LDError: No data to return, please check errors: ERROR: No successful response.
(403, <html>
<head>
<title>Forbidden</title>
<style type="text/css">
body {
background-color: #242424;
color: #c8c7c7;
font-family: Calibri, Helvetica, Arial, sans-serif;
font-size: 16px;
}
</style>
</head>
<!-- Response
Server: PLNP-ERPA01
Date: Tue, 10 Jun 2025 22:36:05 GMT
HTTP Code: 403
HTTP Response: Forbidden
X-Varnish: 71236781
Backend: default
-->
<body>
<h1>Forbidden</h1>
<p>Invalid token</p>
</body>
</html>)
```

How can I fix this/what am I doing wrong?

Answers

  • Hello @davidk

    Based on my knowledge, the ld.get_history (Access Layer) and ld.content.historical_pricing.summaries (Content Layer) interfaces request historical data from different endpoint.

    To let us check this behavior in detail, could you please give us more detail as follows?

    • Are you using the Desktop Session or Platform Session?
    • If you can replicate the issue on demand, please enable the debug log and share the log on this post.

    You can enable the debug log via lseg-data.config.json file as follows:

    {
    "logs": {
    "level": "debug",
    "transports": {
    "console": {
    "enabled": false
    },
    "file": {
    "enabled": true,
    "name": "lseg-data-lib.log"
    }
    }
    },
    "sessions": {
    "default": "xxxx",
    }
    }