Implementing JWT authentication for JIRA API with Python

Hey everyone, I’m trying to figure out how to use JWT for JIRA API access using Python. The Python JIRA library doesn’t have clear docs on this. I’ve looked at the source code and found some info about credentials, but I’m not sure how to get or use them.

Here’s what I’ve found in the code:

def authenticate(self, secret, payload):
    # JWT authentication
    # secret: shared secret from JIRA
    # payload: dict with fields like 'iss' for the JWT payload
    # Example: {'secret': 'MY_SECRET', 'payload': {'iss': 'MY_PLUGIN_KEY'}}
    pass

I’ve checked JIRA docs, but they mostly talk about JWT for add-ons. I thought JWT was about using a username and password to get a token, then using that token. But the JIRA docs seem more complex than that.

Can anyone explain how to set this up or point me to some simpler instructions? I’m a bit lost here. Thanks!

hey, tried the jwT mess with jira too. i used the ‘atlassian-oauth2’ library. set up the app, grabbed the client id & secret, then let the lib handle token gen. much easier than DIY. good luck!

I had a run-in with JWT authentication for the JIRA API and eventually figured out a strategy that worked. My experience showed me that the process isn’t as straightforward as using a username and password. You first need to configure an application link in JIRA to obtain a consumer key and shared secret. Then you generate a JWT token with a library like PyJWT while ensuring you include the proper claims such as iss, exp, and qsh. Once the token is ready, you can attach it as a header in your API calls. It took several attempts, but persistence cleared up many doubts along the way.

Having worked with JIRA API authentication, I can attest that JWT implementation can be tricky. The JIRA Python library’s documentation is indeed lacking in this area. From my experience, you’ll need to generate the JWT token separately and then use it with your API requests. I found success using the ‘atlassian-jwt’ library, which simplifies the process considerably. You’ll need to set up an application link in JIRA to get the necessary credentials. Once you have those, you can create a JWT token and include it in the Authorization header of your requests. It’s a bit more involved than simple username/password auth, but it offers better security for API access.