Git Product home page Git Product logo

Comments (23)

cgpu avatar cgpu commented on May 27, 2024 3

I am having the same issue as above reported by @laxmij-cmd.

I am setting as env variables

JIRA_API_TOKEN="<api_token>"  # not base64 encoded, exactly as copied from https://id.atlassian.com/manage-profile/security/api-tokens
JIRA_AUTH_TYPE=bearer

The following command works for me:

curl --request GET \
  --user "<email>:$JIRA_API_TOKEN" \
  --url 'https://<host>.atlassian.net/rest/agile/1.0/board?projectKeyOrId=DEL'

But the jira init command fails with

jira init
? Installation type: Cloud
? Link to Jira server: https://<host>.atlassian.net
? Login email: [email protected]

✗ Received unexpected response '403 Forbidden' from jira. Please try again.

We tried with my organisation admin and they also have the same issue, so I can rule out the problem being insufficient permissions.

Any idea what I may be doing wrong?

from jira-cli.

ankitpokhrel avatar ankitpokhrel commented on May 27, 2024 2

Hey Folks, I'll look into this this week. Could you please provide some more details like:

  • If this is jira cloud or jira server
  • If using jira server, what version of Jira is it
  • Any other details that may be helpful to debug the issue

Also, if you are using Jira Cloud you may NOT need to set JIRA_AUTH_TYPE=bearer. API tokens in cloud is different from PAT in on-premises installation IIRC.

from jira-cli.

rcoleman-hivewatch avatar rcoleman-hivewatch commented on May 27, 2024 2

fwiw i was struggling with the same issue but when i unset JIRA_AUTH_TYPE and ran jira init again, things worked.

from jira-cli.

choman avatar choman commented on May 27, 2024 1

@laxmij-cmd Make sure you have both JIRA_API_TOKEN=<api_token> and JIRA_AUTH_TYPE=bearer

from jira-cli.

mattiapesentiAGADE avatar mattiapesentiAGADE commented on May 27, 2024 1

I noticed the same behavior on Windows 10 under Git Bash (MINGW64_NT-10.0-19045). The curl request works, but then jira init fails with ✗ Received unexpected response '403 Forbidden' from jira. Please try again.

I'm using this version:

$ jira version
(Version="1.5.1", GitCommit="0e0f82d52ef5a775d2cc662fbe38d9732b9b5c59", CommitDate="2024-01-20T10:48:06+00:00", GoVersion="go1.21.5", Compiler="gc", Platform="windows/amd64")

from jira-cli.

ankitpokhrel avatar ankitpokhrel commented on May 27, 2024 1

HI @Drew-Daniels, its a cloud installation if your domain is {host}.atlassian.net. Please select Cloud as installation type and try again.

from jira-cli.

laxmij-cmd avatar laxmij-cmd commented on May 27, 2024

updating:

Login username:

With I can login to our jira server.

from jira-cli.

laxmij-cmd avatar laxmij-cmd commented on May 27, 2024

not sure why login-id is getting removed

from jira-cli.

ankitpokhrel avatar ankitpokhrel commented on May 27, 2024

@laxmij-cmd do you still need help?

from jira-cli.

armadsen avatar armadsen commented on May 27, 2024

I'm having the same problem. I'm on macOS 14.2.1 with ZSH. I've set JIRA_API_TOKEN and JIRA_AUTH_TYPE in .zshrc. When I run Jira init, provide my JIRA instance URL, then login email, I get:

Received unexpected response '403 Forbidden' from jira. Please try again.

As with others, using curl returns the expected data.

from jira-cli.

erawhctim avatar erawhctim commented on May 27, 2024

Same problem here. I've tried installed a handful of versions (1.5.4, 1.5.0, 1.4.0, 1.2.0), all see the same issue.

from jira-cli.

erawhctim avatar erawhctim commented on May 27, 2024

@ankitpokhrel What information can we get you that's most helpful to debug, if anything?

from jira-cli.

erawhctim avatar erawhctim commented on May 27, 2024

I'm using Jira Cloud, version 1001.0.0-SNAPSHOT (how to find out your JIra Cloud version)

Removing the auth type param seems to have the same effect; I get a 401 Unauthorized.

This curl command succeeds:
curl https://{host}.atlassian.net/rest/api/2/myself --user {email}:$JIRA_API_TOKEN

This jira-cli fails:
jira init --force --installation cloud --server "https://{host}.atlassian.net" --login "{email}" --debug

from jira-cli.

mattiapesentiAGADE avatar mattiapesentiAGADE commented on May 27, 2024

Same here
Jira cloud version 1001.0.0-SNAPSHOT

$ jira init --installation cloud --server "https://<host>.atlassian.net" --login "<email>" --debug
⠇ Verifying login details...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/myself HTTP/1.1
Host: <host>.atlassian.net
Authorization: Bearer <JIRA_API_TOKEN>


✗ Received unexpected response '403 Forbidden' from jira. Please try again.

EDIT: I changed the auth type (removed the env variable JIRA_AUTH_TYPE=bearer and it worked!

from jira-cli.

armadsen avatar armadsen commented on May 27, 2024

Exact same thing as @mattiapesentiAGADE. I'm on Jira cloud version 1001.0.0-SNAPSHOT.

I've also just tried removing the JIRA_AUTH_TYPE=bearer ENV variable, and it works now!

from jira-cli.

ankitpokhrel avatar ankitpokhrel commented on May 27, 2024

I'm using Jira Cloud, version 1001.0.0-SNAPSHOT (how to find out your JIra Cloud version)

Removing the auth type param seems to have the same effect; I get a 401 Unauthorized.

This curl command succeeds: curl https://{host}.atlassian.net/rest/api/2/myself --user {email}:$JIRA_API_TOKEN

This jira-cli fails: jira init --force --installation cloud --server "https://{host}.atlassian.net" --login "{email}" --debug

Hi @erawhctim, This is strange as I've the same setup and is working fine. Could you please double check the params you are passing to jira-cli and provide any additional context that might be helpful to debug?

from jira-cli.

erawhctim avatar erawhctim commented on May 27, 2024

I'm creating my PAT via: Account Icon -> Profile -> Security -> Create and Manage API tokens. I can confirm that this value is set correctly for the JIRA_API_TOKEN env. var; is there another way to set this value that I can try?
I just created a new PAT this way and tried with that (using the exact script I posed); same result.

My org uses Okta SSO to authenticate with our Jira instance, so perhaps some non-standard auth. setup is interfering here.

Another thing I tried is running this same script within our CI environment, which has an org-level, pre-provisioned Jira API token & service user. That seems to be working! So this might just be something that I can't run locally with user-created PAT's.

Can you help me better understand the auth. request that happens when init is called? I'd like to take this back to our Atlassian tools admins and try and debug further (it'd be nice if we could figure out how to enable people to use jira-cli locally).

from jira-cli.

oren-adhoc avatar oren-adhoc commented on May 27, 2024

make sure to export JIRA_API_TOKEN in your environment:

export JIRA_API_TOKEN=xxxxx

from jira-cli.

Drew-Daniels avatar Drew-Daniels commented on May 27, 2024

Same issue here. I've set these in my ~/.zshrc:

JIRA_AUTH_TYPE=bearer
JIRA_API_TOKEN=<my-token>

I can verify these return the expected values with echo, and I can successfully run this curl command:

$ curl https://{host}.atlassian.net/rest/api/2/myself --user {email}:$JIRA_API_TOKEN

But when I run jira init and select "Local", enter my Jira server, and my login username, I get a 403 error response.

$ jira init

image

Installed jira-cli with brew as described here

$ jira version
(Version="1.5.1", GitCommit="0e0f82d52ef5a775d2cc662fbe38d9732b9b5c59", CommitDate="2024-01-20T10:48:06+00:00", GoVersion="go1.21.5", Compiler="gc", Platform="darwin/arm64")

image

from jira-cli.

Drew-Daniels avatar Drew-Daniels commented on May 27, 2024

HI @Drew-Daniels, its a cloud installation if your domain is {host}.atlassian.net. Please select Cloud as installation type and try again.

Ah, my mistake. Thanks for pointing that out. As soon as I removed the JIRA_AUTH_TYPE env var from .zshrc and chose Cloud as the installation type jira init worked.

Thank you!

from jira-cli.

ankitpokhrel avatar ankitpokhrel commented on May 27, 2024

@erawhctim

My org uses Okta SSO to authenticate with our Jira instance, so perhaps some non-standard auth. setup is interfering here.

Strange! My org uses Okta SSO too and I don't have any issue with the tokens.

Can you help me better understand the auth. request that happens when init is called?

It basically calls bunch of JIRA API to generate the config file. First it verifies login details using /myself endpoint, and if that's successful it will fetch project and board details.

from jira-cli.

pot8228 avatar pot8228 commented on May 27, 2024

I had the same problem. New Jira Cloud instance, authorised through Apple ID. Jira init 403'd each time. PAT seemed to be fine, I could curl with it.

The fix, as per the last comment, was to remove JIRA_AUTH_TYPE=bearer from my environment variables. Connects fine now.

from jira-cli.

justinphelps avatar justinphelps commented on May 27, 2024

FWIW. I went through ALL the troubleshooting steps I could find trying to resolve 401s for a couple of days.
I had a brand new fresh cloud install.
What finally worked as creating a second, non-privileged user with another email address and it finally worked.
I'm guessing there is some permission that is excluded from users with the jira-admin role.

from jira-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.