401 Unauthorized - Basic authorization with passwords is deprecated

I’m trying to integrate Jira with a Slack app and am having trouble with the Jira’s REST API. I’m using the basic auth for the sake of simplicity, as I simply want to fetch projects. I’ve created an API token and granted project permissions via the default project permissions scheme with both browse projects and administrate projects options selected. My request returns a 401 Unauthorized error with the message: “Basic authentication with passwords is deprecated.”

Based on other suggestions, I tried resetting my password but that did not help.

Here is my code:

fetch('https://<domain>.atlassian.net/rest/api/2/project/search', {
        method: 'GET',
        headers: {
            'Authorization': `Basic ${Buffer.from(
                `<myEmail>:${process.env.JIRA_KEY}`
            ).toString('base64')}`,
            'Accept': 'application/json'
        }
    })
        .then(response => {
            console.log(
                `Response: ${response.status} ${response.statusText}`
            );
            return response.text();
        })
        .then(text => console.log(text))
        .catch(err => console.error(err));

Hi @robertosborn,
the code provided by you looks fine and works for me.

Can you double check that you have created an API token in a proper place?
Clicking on your avatar -> Account settings -> Security -> Create and manage API tokens.

Can you confirm that the token that you are using is listed there? What’s about Last accessed date, can you see any relevant date there or Never Accessed?

The reason why I’m asking is that we have two different places where API keys can be generated. The second one is in Atlassian Administration and I’d like to make sure you are using a proper key.

Hi @BeataSzturemska ,

I had same trouble. I already generated api tokens but my Last Accessed info showed “Never Accessed”. Is there any wrong with that? Thanks