<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic rumUserSessionsClient API error in AUTH in Dynatrace API</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-API/rumUserSessionsClient-API-error-in-AUTH/m-p/221847#M2632</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From the documentation I have seen that the portion of the code needed to fetch the data of&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;user session query&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but whenever I call this method I get this error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Request failed: {"code":403,"message":"OAuth token is missing required scope. Use one of: [environment-api:usersessionquerylanguage:read]"}&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the previous version of dynatrace I used to create an&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;API token&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;and put it on the header of the HTTP call to dynatrace.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In another application, I used to call the dynatrace user session query:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;In this new version of dynatrace, it seems that the authentication method has been changed... especially in the developement of the app.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Andrea&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Aug 2023 10:48:41 GMT</pubDate>
    <dc:creator>andreaCaria</dc:creator>
    <dc:date>2023-08-29T10:48:41Z</dc:date>
    <item>
      <title>rumUserSessionsClient API error in AUTH</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/rumUserSessionsClient-API-error-in-AUTH/m-p/221847#M2632</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From the documentation I have seen that the portion of the code needed to fetch the data of&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;user session query&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but whenever I call this method I get this error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Request failed: {"code":403,"message":"OAuth token is missing required scope. Use one of: [environment-api:usersessionquerylanguage:read]"}&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the previous version of dynatrace I used to create an&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;API token&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;and put it on the header of the HTTP call to dynatrace.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In another application, I used to call the dynatrace user session query:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;In this new version of dynatrace, it seems that the authentication method has been changed... especially in the developement of the app.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Andrea&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 10:48:41 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/rumUserSessionsClient-API-error-in-AUTH/m-p/221847#M2632</guid>
      <dc:creator>andreaCaria</dc:creator>
      <dc:date>2023-08-29T10:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: rumUserSessionsClient API error in AUTH</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/rumUserSessionsClient-API-error-in-AUTH/m-p/222499#M2637</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 12:44:08 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/rumUserSessionsClient-API-error-in-AUTH/m-p/222499#M2637</guid>
      <dc:creator>ChadTurner</dc:creator>
      <dc:date>2023-09-07T12:44:08Z</dc:date>
    </item>
  </channel>
</rss>

