-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
Add option to add custom headers to Jira Client (or enable token Bearer auth at least) #989
Comments
I've forked the repo and added token auth option: https://github.com/skaiaa/jira/blob/master/jira/client.py |
Apparently on JIRA constructor it makes a copy of JIRA.DEFAULT_OPTIONS dictionary then it uses options parameter to update internal options, try something like: headers = JIRA.DEFAULT_OPTIONS["headers"].copy()
headers["my-header"] = "my value"
jira = JIRA(options={"headers": headers}) |
Thanks! It worked for me :) I've created PR with token auth added, so maybe it'll be useful and more clean fix for the future. #991 |
To be entirely clear to anyone looking to use a Personal Access token - @danielflira's excellent workaround would look like this: host = "YOUR_JIRA_URL"
pat = "YOUR_PERSONAL_ACCESS_TOKEN"
headers = JIRA.DEFAULT_OPTIONS["headers"].copy()
headers["Authorization"] = f"Bearer {pat}"
jira=JIRA(server=host, options={"headers": headers}) |
A nice solution, but does not allow to use client-side TLS certificates. This is the (terrible) hack which did it for me class JIRA_With_Token_Auth(jira.JIRA):
"""This is a HORRIBLE HACK to cope with the lack of real support for Personal Access Token authentication
"""
def _create_http_basic_session(self, username, password, timeout=None):
verify = self._options['verify']
self._session = jira.client.ResilientSession(timeout=timeout)
self._session.verify = verify
# if they are empty, leave _session.auth=None
if username and password:
self._session.auth = (username, password)
self._session.cert = self._options['client_cert']
j = JIRA_With_Token_Auth(server, basic_auth=(None,None), options=dict(client_cert=cert)) |
I have to login to Jira using a Token with header like this "authetication":"Bearer <TOKEN>". There is no option to add headers manually and token auth is not one of the provided ways to authenticate. This blocks me from using a client at all, because I cannot authenticate properly.
Please, consider adding an option for custom headers. Is there a workaround which would make token bearer authentication work?
The text was updated successfully, but these errors were encountered: