Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication with bearer token #94

Closed
smaritem opened this issue Sep 5, 2022 · 10 comments
Closed

Authentication with bearer token #94

smaritem opened this issue Sep 5, 2022 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@smaritem
Copy link

smaritem commented Sep 5, 2022

Hello Prince,

the autentication doesnt work with the bearer token. In our company we can only retrieve data over a login with bearer token.
Can you help us with the autentication?

Thanks & best regards
Smari

@princenyeche princenyeche self-assigned this Sep 5, 2022
@princenyeche princenyeche added the question Further information is requested label Sep 5, 2022
@princenyeche
Copy link
Owner

@smaritem To use a Bearer token, you will need to call the token_session() method.

from jiraone import LOGIN, endpoint

# previous statement
# You must declare a base_url
url = "https://yourinstance.atlassian.net"
token = "GHxxxxxPPPxx" # Your bearer token
# First assign a base_url to the attribute below
LOGIN.base_url = url
# You need to pass the token variable to a keyword argument called `sess`
LOGIN.token_session(sess=token)
# Afterwards you can make calls such as
data = LOGIN.get(endpoint.myself())
print(data.status_code)
# result
# 200

@smaritem
Copy link
Author

smaritem commented Sep 5, 2022

@princenyeche , thanks for the reply

I am getting an unknow error with the code PROJECT.change_log(jql=jql) , where jql = r'project = "project name" '

image001

@princenyeche
Copy link
Owner

You should not use a raw string identifier r for your strings.
Do this ✅

jql = 'project = "project name"'

Don't do this ❌

jql = r'project = "project name" '

princenyeche added a commit that referenced this issue Sep 5, 2022
Minor update to v0.7.0 #93
@princenyeche
Copy link
Owner

@smaritem Let me know if you got it working for yourself?

@smaritem
Copy link
Author

@princenyeche

I tried it, but still dont work. I am getting an empty csv file
running

I also tried
load = LOGIN.get(endpoint.get_all_priorities() )

I am getting the repsonse 200, but the text doesnt contain the data.
responseText

How can I get the history in the changelog.csv file using the rest api URL, /rest/api/... ?

@princenyeche
Copy link
Owner

@smaritem
From your screenshot, it doesn't seem that there's any history from that JQL. The usual message on screen should show the issues where the history is being extracted from
e.g

Extracting issue histories...
Getting history from IP-132

So if the CSV file is empty, does it include any headers? If yes, there is probably no history of the issues being queried. Probably what you can do is simply test it on a single issue history instead.
e.g

jql = "key = ABC-123"

@smaritem
Copy link
Author

@princenyeche that jql gives back more than 10000 issues, and most of them do have histories

Is there an alternative to PROJECT.change_log(jql=jql) , where jql = 'project = "project name" '
Or how can we use it witht the rest API url https://server_name.net/rest/api/..?

@princenyeche
Copy link
Owner

princenyeche commented Sep 12, 2022

@smaritem Your base_url must point to your instance URL, so if you're a server, let it be to the API endpoint that is available. e.g. https://server_name.net just the base_url only. Also, if it's on a server then you might want to add LOGIN.api = False before calling the authentication method.

LOGIN.api = False
# before calling token_session method?
LOGIN.token_session(sess=token)

@smaritem
Copy link
Author

@princenyeche ,
thanks, it works with
LOGIN.api = False

@princenyeche
Copy link
Owner

Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants