jira ls - no issues => implement better error handling
Closed this issue ยท 26 comments
Just installed jira cmd
and jira ls gives me no issues
.
I'm using jira cloud (not hosted jira).
I guess that something is happening under the hood but no error is thrown so I can tell what is the cause.
jira -V
v0.5.4
hey @bartmoc can you please check in the jira panel if you actually have any issues with the status mentioned in ~/.jira/config.json in the array available_issues_statuses .
If you have no issues there then you can add the required status in available_issues_statuses to get those issues in jira ls.
If you have issues in the available_issues_statuses statuses , then it must be an auth issue.
- Can you please confirm if you are able to create new issue using jira new command.
- Also can you please confirm if you have any third party auth before jira like google auth.
Looks like auth issue:
jira new "DasdAS"
Error: got 401 response
Error: got 401 response
When logging via the web browser I'm not using OAuth (like google auth), I'm using username and password.
@palashkulsh If it's an auth issue, is there a way to enable more verbose (more logs) mode, so I can find out what is happening?
sure, let me share a branch with you which can enable more verbose logs. give me 5 mins.
can you please check if your token is correct. by echo "TOKEN" | base64 -d so that it is correct. with username and password.
TOKEN can be found in your ~/.jira/config.json
My token resolves to
myemail:password
then it seems correct. let me share the branch asap
also in the meantime can you please check if there is https in your supplied url in config.json
node jira.js ls
{ Error: got 401 response
at Response.toError (/home/bmocior/dev/private/jira-cmd/node_modules/superagent/lib/node/response.js:100:13)
at Response.setStatusProperties (/home/bmocior/dev/private/jira-cmd/node_modules/superagent/lib/node/response.js:179:12)
at new Response (/home/bmocior/dev/private/jira-cmd/node_modules/superagent/lib/node/response.js:40:8)
at IncomingMessage.<anonymous> (/home/bmocior/dev/private/jira-cmd/node_modules/superagent/lib/node/index.js:712:22)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19) status: 401 }
Yes, it contains https
https://****.atlassian.net/
cool.
can you please try
npm -g i git+https://git@github.com/germanrcuriel/jira-cmd.git#debug
jira ls
sudo npm -g i git+https://git@github.com/germanrcuriel/jira-cmd.git#debug
npm WARN deprecated superagent@0.13.0: Please note that v5.0.1+ of superagent removes User-Agent header by default, therefore you may need to add it yourself (e.g. GitHub blocks requests without a User-Agent header). This notice will go away with v5.0.2+ once it is released.
/usr/bin/jira -> /usr/lib/node_modules/jira-cmd/bin/jira.js
> jsonpath@1.0.2 postinstall /usr/lib/node_modules/jira-cmd/node_modules/jsonpath
> node lib/aesprim.js > generated/aesprim-browser.js
sh: 1: cannot create generated/aesprim-browser.js: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! jsonpath@1.0.2 postinstall: `node lib/aesprim.js > generated/aesprim-browser.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the jsonpath@1.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/bmocior/.npm/_logs/2019-08-14T10_37_43_173Z-debug.log
โ bin git:(debug) โ
What authentication are you using? Maybe with jira cloud, basic auth is not permitted?
I check via CURL that for some reasons basic auth doesn't work on my Jira instance and basic auth is deprecated in favour of OAuth... So unfortunately I won't be able to use this cli :( Anyway, thx for help.
that really sucks. Sorry brother.
Do you have any doc for oauth support, may be i can add that functionality in development pipeline of the project.
It will help other users of jira-cmd.
No worries, thx for an effort.
Documentation for it here:
https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/
thanks @bartmoc
@palashkulsh they are supporting api tokens -> quite simple
https://confluence.atlassian.com/cloud/api-tokens-938839638.html
@palashkulsh When I set this API token instead of password it works!
Oh i forgot to mention the auth token part. Really glad you are able to use the jira-cmd . Its really convenient.
Adding this info to documentation would nice :)
thanks created issue for this.
Looks like some mixup on documenting the solution when using a token instead of a password. The issued referred to just above (#93) points to a commit that has nothing to do with documenting the solution here.
So to save some other folks time in figuring it out, here is what should be documented from my experiments ultimately leading to a successful connection for an OAuth-based login.
- Navigate to your Atlassian token management page: https://id.atlassian.com/manage-profile/security/api-tokens
- Create a token; call it whatever you want; but you should end up something like this:
- Copy that token.
- If you have already tried configuring
jira-cli
delete your~/.jira/config.json
file. - Run
jira
to start the configuration again. - Go through the dialog, but instead of entering a password, enter the token from line (3).
% jira
Jira URL: https://<your-org-here>.atlassian.net/
Username: <your-org-email>
Password: <your-token>
Information stored!
- Confirm your information is stored correctly in the configuration:
% grep token ~/.jira/config.json | awk -F \" '{print $4}' | base64 -d
The output should be
<your-org-email>:<your-token>
- Test your connection:
% jira ls
Thanks @msorens for the detailed process
Some organizations disable Basic auth entirely - regardless if you use a password or an API token - and there the solution is to use the HTTP header Authorization: Bearer <apitoken>
.
I used an ugly workaround to find/replace all "Basic" with "Bearer", and made sure config.auth.token was the API token generated by JIRA.
@Peksa thats a great find, I'll add its support in a new release