Authentication with bearer token
smaritem opened this issue · 10 comments
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
@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
@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" '
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" '
@smaritem Let me know if you got it working for yourself?
@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"
@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/..?
@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)
@princenyeche ,
thanks, it works with
LOGIN.api = False
Great.