5

I tried using Python JIRA client with following code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from jira.client import JIRA

jira = JIRA(options={'server': 'http://server.atlassian.net'},
            basic_auth=('email@example.com', 'pass'))

projects = jira.projects()

for v in projects:
    print v

And I got following error:

Got recoverable error from GET https://server.atlassian.net/rest/api/2/serverInfo, will retry [1/3] in 17.5832343958s. Err: 401 Unauthorized

Using python 2.7 (virtualenv), installed using pip install jira. I tried using my username and email and am certain that my login credentials are correct (I can login using my browser with same credentials without a problem). Any tips what am I doing wrong?

metalcamp
  • 526
  • 1
  • 6
  • 14
  • 401 is the error code you'd expect to see if the credentials were wrong. Maybe try requesting it using Postman and see if you can reproduce the error? – Matthew Daly Nov 06 '17 at 22:36
  • True, 401 is self explanatory. Tried using username (which is not the same as email) and still got same error. Changed password (although it was 100% correct, I could successfully login with it) and now everything works as expected. – metalcamp Nov 07 '17 at 07:23

1 Answers1

5

Suggest to go here: https://id.atlassian.com/manage/api-tokens and create an API token.

To connect with the Python JIRA client, use your email address as the username, and the token value as the password.

JamesJJ
  • 874
  • 8
  • 11
  • 1
    @MaciejJureczko ... I did ;) To reliably authenticate, you should use an API token instead of your usual login credentials. The link is the address where JIRA cloud customers can create an API token. – JamesJJ Apr 18 '19 at 13:43