pawelrychlik / jira-dependency-graph

Graph visualizer for JIRA tickets' dependencies
MIT License
282 stars 90 forks source link

Add bearer auth with JIRA Personal Access Token #49

Closed blesenechal closed 7 months ago

blesenechal commented 2 years ago

Add ability to login using an OAuth token, such as Personal Access Token.

Regenhardt commented 1 year ago

Edit: disregard that I thought this was an issue and not a finished PR lol. Definitely gonna add this to mine.

pawelrychlik commented 7 months ago

Thanks!.

vanderzielj commented 3 months ago

The token-handling logic as of commit 6350fb7 failed with "Failed to parse Connect Session Auth Token". According to a comment in a Jira community forum,

Apparently the Jira documentation about this was wrong. We shouldn't use Bearer authentication, but instead try to authenticate with OAuth1 standart.

The recommended approach is to use HTTPBasicAuth from from requests.auth. Using this approach resolved the error for me. I modified your logic in main as follows:

    if options.bearer is not None:
        # Generate JIRA Personal Access Token and use --bearer=ABCDEF012345 commandline argument
        # auth = {'Authorization': 'Bearer ' + options.bearer}

        # the above doesn't work: "Failed to parse Connect Session Auth Token"
        # see https://community.atlassian.com/t5/Jira-questions/How-to-deal-with-quot-Failed-to-parse-Connect-Session-Auth-Token/qaq-p/829057
        user = options.user if options.user is not None else input("Username: ")
        auth = HTTPBasicAuth(user, options.bearer)