Python library for interacting with JIRA via REST APIs.
—
Configuration and authentication options for connecting to JIRA instances. The library supports multiple authentication methods including Basic Auth, OAuth, JWT, and Kerberos.
Primary interface for creating JIRA client connections with comprehensive authentication and configuration options.
class JIRA:
def __init__(
self,
server: str = None,
options: dict = None,
basic_auth: tuple = None,
oauth: dict = None,
jwt: dict = None,
kerberos: bool = False,
kerberos_options: dict = None,
validate: bool = False,
get_server_info: bool = True,
async_: bool = False,
async_workers: int = 5,
logging: bool = True,
max_retries: int = 3,
proxies: dict = None,
timeout: int = None,
auth = None
):
"""
Construct a JIRA client instance.
Parameters:
- server: JIRA server URL (default: http://localhost:2990/jira)
- options: Dict of server configuration options
- basic_auth: Tuple of (username, password) for HTTP basic authentication
- oauth: Dict of OAuth authentication parameters
- jwt: Dict of JWT authentication parameters for Atlassian Connect
- kerberos: Boolean to enable Kerberos authentication
- kerberos_options: Dict of Kerberos authentication options
- validate: Boolean to validate credentials during instantiation
- get_server_info: Boolean to fetch server version info
- async_: Boolean to enable asynchronous operations
- async_workers: Number of worker threads for async operations
- logging: Boolean to enable logging
- max_retries: Maximum number of retries for failed requests
- proxies: Dict of proxy configuration
- timeout: Request timeout in seconds
- auth: Custom authentication object
"""Usage examples:
Basic Authentication:
from jira import JIRA
# Simple connection with basic auth
jira = JIRA(
server='https://your-jira-instance.com',
basic_auth=('username', 'password')
)OAuth Authentication:
oauth_dict = {
'access_token': 'your-access-token',
'access_token_secret': 'your-access-token-secret',
'consumer_key': 'your-consumer-key',
'key_cert': 'path/to/private-key.pem'
}
jira = JIRA(
server='https://your-jira-instance.com',
oauth=oauth_dict
)JWT Authentication (Atlassian Connect):
jwt_dict = {
'secret': 'your-shared-secret',
'payload': {
'iss': 'your-plugin-key'
}
}
jira = JIRA(
server='https://your-jira-instance.com',
jwt=jwt_dict
)Custom Options:
options = {
'server': 'https://your-jira-instance.com',
'rest_path': 'api',
'rest_api_version': '2',
'verify': True,
'resilient': True,
'async': False,
'headers': {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json'
}
}
jira = JIRA(options=options, basic_auth=('username', 'password'))Convenient function for loading JIRA connection details from configuration files.
def get_jira(
profile: str = None,
url: str = "http://localhost:2990",
username: str = "admin",
password: str = "admin",
appid: str = None,
autofix: bool = False,
verify: bool = True
) -> JIRA:
"""
Return a JIRA object by loading connection details from config file.
Parameters:
- profile: Section name from config.ini file
- url: JIRA server URL
- username: Username for authentication
- password: Password for authentication
- appid: Application ID
- autofix: Boolean for auto-fixing issues
- verify: Boolean for SSL certificate verification
Returns:
Configured JIRA client instance
"""Usage example:
from jira import get_jira
# Load from default profile in config file
jira = get_jira()
# Load from specific profile
jira = get_jira(profile='production')
# Override specific settings
jira = get_jira(
profile='development',
url='https://dev-jira.company.com',
verify=False
)Methods for managing JIRA sessions and authentication state.
def session(self, auth = None) -> dict:
"""Get current session information."""
def kill_session(self) -> None:
"""Destroy the current session."""
def kill_websudo(self) -> None:
"""Destroy WebSudo session."""Methods for retrieving server and connection information.
def server_info(self) -> dict:
"""Get JIRA server information including version and build details."""
def myself(self) -> User:
"""Get information about the current authenticated user."""
def client_info(self) -> dict:
"""Get client connection information."""Usage examples:
# Get server information
server_info = jira.server_info()
print(f"JIRA Version: {server_info['version']}")
print(f"Build Number: {server_info['buildNumber']}")
# Get current user
current_user = jira.myself()
print(f"Logged in as: {current_user.displayName}")
print(f"Email: {current_user.emailAddress}")
# Get session details
session_info = jira.session()
print(f"Session Name: {session_info['name']}")HTTP Basic authentication using username and password:
jira = JIRA(server='https://jira.company.com', basic_auth=('user', 'pass'))OAuth authentication for applications:
oauth = {
'access_token': 'token',
'access_token_secret': 'secret',
'consumer_key': 'key',
'key_cert': '/path/to/private.pem'
}
jira = JIRA(server='https://jira.company.com', oauth=oauth)JWT authentication for Atlassian Connect apps:
jwt = {
'secret': 'shared-secret',
'payload': {'iss': 'plugin-key'}
}
jira = JIRA(server='https://jira.company.com', jwt=jwt)Kerberos authentication for enterprise environments:
jira = JIRA(
server='https://jira.company.com',
kerberos=True,
kerberos_options={'mutual_authentication': 'DISABLED'}
)The options parameter accepts the following configuration keys:
server: Server URL (default: http://localhost:2990/jira)rest_path: REST API path (default: api)rest_api_version: REST API version (default: 2)agile_rest_path: Agile API path (default: greenhopper)verify: SSL certificate verification (default: True)client_cert: Client certificate tuple for SSLresilient: Enable resilient session with retries (default: True)async: Enable async operations (default: False)async_workers: Number of async worker threads (default: 5)headers: Custom HTTP headers dictionarycookies: Custom cookies dictionaryInstall with Tessl CLI
npx tessl i tessl/pypi-jira@2.0.2