MrRefactoring / jira.js

A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API
https://mrrefactoring.github.io/jira.js/
MIT License
349 stars 46 forks source link

PAT doesn't full login user #237

Closed MrPatryk closed 1 year ago

MrPatryk commented 1 year ago

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?

MrRefactoring commented 1 year ago

Hello @MrPatryk! Let me check

MrPatryk commented 1 year ago

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.

MrRefactoring commented 1 year ago

Do you use PAT for Jira cloud or Jira Server?

MrPatryk commented 1 year ago

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

MrRefactoring commented 1 year ago

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 :(

MrPatryk commented 1 year ago

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

bluesky12 commented 10 months ago

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

kouchao commented 10 months ago

I also encountered the same issue

nvuillam commented 6 months ago

Same here with jira server :/

MrRefactoring commented 6 months ago

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

nvuillam commented 6 months ago

@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 ? :)

MrRefactoring commented 6 months ago

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

nvuillam commented 6 months ago

That's indeed a good reason :)

Thanks for the reply :)