File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ def __init__(
5151 kerberos = None ,
5252 cloud = False ,
5353 proxies = None ,
54+ token = None ,
5455 ):
5556 self .url = url
5657 self .username = username
@@ -69,6 +70,8 @@ def __init__(
6970 self ._session = session
7071 if username and password :
7172 self ._create_basic_session (username , password )
73+ elif token is not None :
74+ self ._create_token_session (token )
7275 elif oauth is not None :
7376 self ._create_oauth_session (oauth )
7477 elif oauth2 is not None :
@@ -87,6 +90,9 @@ def __exit__(self, *_):
8790 def _create_basic_session (self , username , password ):
8891 self ._session .auth = (username , password )
8992
93+ def _create_token_session (self , token ):
94+ self ._update_header ("Authorization" , "Bearer {token}" .format (token = token ))
95+
9096 def _create_kerberos_session (self , _ ):
9197 from requests_kerberos import HTTPKerberosAuth , OPTIONAL
9298
Original file line number Diff line number Diff line change @@ -152,6 +152,19 @@ Or reuse cookie file:
152152 url = ' http://localhost:8080' ,
153153 cookies = cookie_dict)
154154
155+ Or using Personal Access Token
156+ Note: this method is valid for Jira Data center / server editions only! For Jira cloud, see below.
157+
158+ First, create your access token (check https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html for details)
159+ Then, just provide the token to the constructor:
160+
161+ .. code-block :: python
162+
163+ jira = Jira(
164+ url = ' https://your-jira-instance.company.com' ,
165+ token = jira_access_token
166+ )
167+
155168 To authenticate to the Atlassian Cloud APIs Jira, Confluence, ServiceDesk:
156169
157170.. code-block :: python
You can’t perform that action at this time.
0 commit comments