# rumUserSessionsClient API error in AUTH

**URL:** <https://community.dynatrace.com/t/rumusersessionsclient-api-error-in-auth/41408>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api, tokens\
**Created:** [August 29, 2023, 10:48am UTC](https://community.dynatrace.com/t/rumusersessionsclient-api-error-in-auth/41408 "2023-08-29T10:48:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreaCaria](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@andreaCaria](https://community.dynatrace.com/u/andreaCaria)\
**Post date:** [August 29, 2023, 10:48am UTC](https://community.dynatrace.com/t/rumusersessionsclient-api-error-in-auth/41408/1 "2023-08-29T10:48:41Z")

</div>

Hi all,

I’m developing a dynatrace app and I would like to get the data for the user session query API as I have always done from Postman

From the documentation I have seen that the portion of the code needed to fetch the data of&nbsp; **user session query** &nbsp;is this:

```javascript
import { rumUserSessionsClient } from "@dynatrace-sdk/client-classic-environment-v1"

export default async function fetchDataUserSession() {
const response = await rumUserSessionsClient.getUsqlResultAsTable({
  query: "SELECT * FROM usersession",
  startTimestamp: 0 ,
  endTimestamp: 0,
  pageOffset: 0
});

```

but whenever I call this method I get this error:

**Request failed: {“code”:403,“message”:“OAuth token is missing required scope. Use one of: [environment-api:usersessionquerylanguage:read]”}**

In the previous version of dynatrace I used to create an&nbsp; **API token** &nbsp;and put it on the header of the HTTP call to dynatrace.

In another application, I used to call the dynatrace user session query:

```python
def callDynatrace(startDate,endDate,query,token,mainUrl ):
    query_params = {
      "query": query,
      "startTimestamp": date_to_milliseconds(startDate),
      "endTimestamp": date_to_milliseconds(endDate),
      "addDeepLinkFields":False,
      "explain": False
    }
    headers = {
      "accept": "application/json",
      "Authorization": "Api-Token " + token
    }

```

In this new version of dynatrace, it seems that the authentication method has been changed… especially in the developement of the app.

Thank you in advance,

Andrea

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [September 7, 2023, 12:44pm UTC](https://community.dynatrace.com/t/rumusersessionsclient-api-error-in-auth/41408/2 "2023-09-07T12:44:08Z")

</div>

easy fix, your token dosnt have the needed read access. Go back in t your Dynatrace UI and make a new tokens with the access as defined in the error message. Existing tokens you cant add permissions to, so tokens and permissions will always be net new FYI.
