Status code 401 - unauthorized / token expired

I am trying to access the /search/beta1 in the Elektron Data Platform for a small proof of concept I am building. I've generated the app key and am including it in the Authorization header in the request. However, when I go to fetch from my front-end, I am being returned an error object that looks like so:

{
code: "401",
id: "e02f9ec2-2986-49d5-ab62-9d066539c9ce",
message: "token expired",
status: "Unauthorized"
}


I am just trying to fetch the same results that is included in the api playground, so my fetching looks like this:


export async function fetchRef() {
    const url = 'https://api.refinitiv.com/search/beta1/';
    const key = '9e2708*********b85abce1f4';
    const response = await fetch(url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            Authorization: "Bearer " + key,
        },
        body: JSON.stringify({
            View: "People",
            Query: "cto microsoft"
        })
    });
    const json = await response.json();
    console.log(json);
}


Is there something I am doing wrong? I cannot seem to find any documentation that would tell me otherwise. I inspected the request that is sent from the api playground, and I noticed the "key" is a much longer one that I was provided in the generator. Am I using the wrong key, and where would I get this new key?

Thank you in advance for your help!

Best Answer

  • Gurpreet
    Answer ✓

    Hi @justin.mckenzie, You seem to be using the Refresh Token instead of Access Token in your request. Please see the EDP tutorials and download the working code samples in Python or Postman.

    PS: This is a public forum, so do not post credentials in the posts. I have removed the key from your question.

Answers