How can I access my Projects details through API

George Nabil Eissa September 28, 2022

I want to access my work through api, I have used. I don't have much knowledge of APIs, So I have used three APIs and all the three gave me issues 401 error unauthorized.

the script is:

 

from jira import JIRA

options = {
'verify': False # Not recommended. I only did this because my certs were messed up!!
}

jira = JIRA(options=options, basic_auth=("username", "pass"))

#Get one story and print out some stuff to show it worked
projects = jira.projects()
issue = jira.issue("xxxxxxxx")

#print (projects)
print (issue)

2 answers

1 accepted

0 votes
Answer accepted
Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 28, 2022

Hey George,

your problem is with using basic_auth, that is no longer supported by Jira Cloud.
You can read about it in the docs of the python project you're using: https://jira.readthedocs.io/examples.html#authentication 

You'll need to use an api_token instead of your password.

You can generate a token in your Atlassian account, as explained here: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

I hope this helps.

Cheers,
Peter

George Nabil Eissa September 28, 2022

Hello Peter Thanks for fast help. The jira is hosted under my company domain. Other thing i have used another API which is atlassian and jiraone and both gave me the same error. 

Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 28, 2022

Hey George, 

In that case you'll need to use Token Auth using a Personal Access Token, as explained here: https://jira.readthedocs.io/examples.html#token-auth
and here: https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html

Cheers,
Peter

George Nabil Eissa September 28, 2022

Thanks Peter, I will test that and update you.

Like # people like this
George Nabil Eissa September 28, 2022

Hay Peter, It worked thankyou.

Monique vdB
Community Manager
Community Managers are Atlassian Team members who specifically run and moderate Atlassian communities. Feel free to say hello!
September 28, 2022

@George Nabil Eissa glad it hear it! it is helpful to the next person if you could mark the answer with "Accept answer" if it helped! :) 

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 28, 2022

Hi @George Nabil Eissa 

You get 401 means that your request reach your Jira instance but you do not have permission. 

It can be related to the fact that the account you are using do not have a valid Jira license or that there is an issue with the authentication part of the call.

 

What language are you using?

Regards 

George Nabil Eissa September 28, 2022

Hello Florain,

very thankful for your support. I have been using Python.

So regarding the Authentication. What would you suggest me to do?

Like Monique vdB likes this
George Nabil Eissa September 28, 2022

Suggest an answer

Log in or Sign up to answer