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 @@ -39,6 +39,7 @@ def __init__(
39
39
url ,
40
40
username = None ,
41
41
password = None ,
42
+ token = None ,
42
43
timeout = 75 ,
43
44
api_root = "rest/api" ,
44
45
api_version = "latest" ,
@@ -69,6 +70,8 @@ def __init__(
69
70
self ._session = session
70
71
if username and password :
71
72
self ._create_basic_session (username , password )
73
+ elif token is not None :
74
+ self ._create_token_session (token )
72
75
elif oauth is not None :
73
76
self ._create_oauth_session (oauth )
74
77
elif oauth2 is not None :
@@ -87,6 +90,9 @@ def __exit__(self, *_):
87
90
def _create_basic_session (self , username , password ):
88
91
self ._session .auth = (username , password )
89
92
93
+ def _create_token_session (self , token ):
94
+ self ._update_header ("Authorization" , "Bearer {token}" .format (token = token ))
95
+
90
96
def _create_kerberos_session (self , _ ):
91
97
from requests_kerberos import HTTPKerberosAuth , OPTIONAL
92
98
Original file line number Diff line number Diff line change @@ -152,6 +152,19 @@ Or reuse cookie file:
152
152
url = ' http://localhost:8080' ,
153
153
cookies = cookie_dict)
154
154
155
+ Or using Personal Access Token
156
+ :warning: valid for Jira Data center / server editions only! For Jira cloud, see below.
157
+
158
+ First, `create your access token https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html `_
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
+
155
168
To authenticate to the Atlassian Cloud APIs Jira, Confluence, ServiceDesk:
156
169
157
170
.. code-block :: python
You can’t perform that action at this time.
0 commit comments