jira-cli: jira init - 401 Unauthorized
Describe the bug
jira init failing with 401 Unauthorized response. but worked with curl requests using the same API token.

Please provide following details
- JiraCLI Version:
(Version="v1.1.1-0.20220814163226-d993757c939c", GitCommit="", CommitDate="", GoVersion="go1.19", Compiler="gc", Platform="linux/amd64") - Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation.
Cloud - What operating system are you using? Also mention version.
Void Linux - What terminal are you using? Also mention version.
foot
To Reproduce
Steps to reproduce the behavior:
- jira init
Expected behavior
should create config file. Screenshots
Additional context
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (6 by maintainers)
great. finally this worked for me. thanks @ankitpokhrel
Ok, apparently it was my bad - by that point of trying to debug I’ve had
export JIRA_AUTH_TYPE="bearer"in my .zshrc which made it not workHere’s how to handle if anyone is facing it: inside your .zshrc include this: export JIRA_API_TOKEN=“<insert token here>” (to create a token go to: https://id.atlassian.com/manage-profile/security/api-tokens)
(make sure you don’t have export JIRA_AUTH_TYPE=“bearer” in your zshrc apparently, bearer token should not be used)
Edit: I still have the issue (it started happening again after a few minutes of working well) I turned on “–debug” and saw this is the issue:
jira issue listis sending this request to JIRA:project=""+ORDER+BY+created+DESC&startAt=0&maxResults=100as you can see the project is empty 🤔 I tried runningjira issue list -p <my_project_key>and it worked this is what I have in my config:I can confirm this issue on Ubuntu 20.04, supplying the api token inline works; but setting the token via
exportorbashrcdoes not.Thanks. But I always use
exportin my env files. @jaerveiHey @akhiljalagam and @viditsi1 ! I had a similar problem but I found out that I made mistake while setting environmental variable. I tried first to add just
JIRA_API_ROKEN="xxxxxxxxxxxxxxxxxxxxx"to my.bashrc. My--debug initgave similar result than yours. Then after 2 min Google I understood to add commandexportto the beginning of line. After that I ran commandsource .bashrc, and voilá, it’s working! So make sure that your.bashrcfile has a line likeexport JIRA_API_ROKEN="xxxxxxxxxxxxxxxxxxxxx". and then run commandsource .bashrc. I hope it will work! 😃