MrRefactoring / jira.js

A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API

Home Page:https://mrrefactoring.github.io/jira.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PAT doesn't full login user

MrPatryk opened this issue · comments

Hello, i try to use example code but i can't even login using just generated PAT.

import { Version3Client } from 'jira.js';

const host = 'https://jira.companydomain.com';

if (!host) {
  throw new Error('Please specify host');
}

const client = new Version3Client({
  host,
  authentication: {
    personalAccessToken: 'MY_PAT'
  },
  newErrorHandling: true
});

async function main() {
  const projects = await client.projects.getAllProjects();
  if (projects.length) {
    const project = projects[0];
    console.dir(project);
    console.log(`'${project.name}' project.`);
  } else {
    const myself = await client.myself.getCurrentUser();
    console.dir(myself);
    console.log("myself");
  }
}
main();

As output i got long HTML doc text which shows that i need to login first -even when in this doc there is my full name etc located in navigation. And below that i got 'undefined' project. I use correct jira host, we can access that without vpn so it should works. Any ideas? Or it's PAT problem in current version?

Hello @MrPatryk! Let me check

You can try code above 😅I even used forti client cli to make 100% sure that is not associated with host access (vpn) by vps running that script. So it's PAT login problem. Need fast solution.

Do you use PAT for Jira cloud or Jira Server?

i don't know i mean: i click on my avatar in menu>profile>Personal Access Tokens and here i generate one

I have tried to test it on Jira Cloud and cannot find this topic (menu -> profile -> PAT). It looks like for Jira Server and unfortunately, I haven't a license for Jira Server to test it :(

Oh okay. Nvm i will try other ways to login :) for me PAT doesn't works in this situation btw.

FYI, I also encountered the same issue, and is resolved by replacing the Version3Client with Version2Client.

I also encountered the same issue

Same here with jira server :/

@nvuillam unfortunately we doesn’t support jira server api.

@MrRefactoring i don't understand... is it on purpose, or because it's too complicated?

You library seems to be the more popular jira api wrapper, nobody ever submitted a PR to make it compliant with half of the jiras of the world ? :)

@nvuillam Jira server will be deprecated at Febrary 2024 and I don't plan to support it :)

That's indeed a good reason :)

Thanks for the reply :)