File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ def __init__(
51
51
kerberos = None ,
52
52
cloud = False ,
53
53
proxies = None ,
54
+ token = None ,
54
55
):
55
56
self .url = url
56
57
self .username = username
@@ -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
+ 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
+
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