jira-auth by 01000001-01001110/agent-jira-skills
npx skills add https://github.com/01000001-01001110/agent-jira-skills --skill jira-auth使用 API 令牌或 OAuth 2.0 通过 Jira Cloud REST API 进行身份验证。处理连接设置、凭证验证和速率限制。
mycompany.atlassian.net)在 jira 技能根目录(.claude/skills/jira/.env)中创建一个 .env 文件:
# 必需
JIRA_EMAIL=user@example.com
JIRA_API_TOKEN=ATATT3xFfGF0...
JIRA_BASE_URL=https://mycompany.atlassian.net
# 可选(显示默认值)
JIRA_PROJECT_KEY=SCRUM
JIRA_BOARD_ID=1
从 .env.example 模板复制:
cp .env.example .env
# 使用你的凭证编辑 .env
Authenticate with Jira Cloud REST API using API tokens or OAuth 2.0. Handle connection setup, credential validation, and rate limiting.
mycompany.atlassian.net)Create a .env file in the jira skill root directory (.claude/skills/jira/.env):
# Required
JIRA_EMAIL=user@example.com
JIRA_API_TOKEN=ATATT3xFfGF0...
JIRA_BASE_URL=https://mycompany.atlassian.net
# Optional (defaults shown)
JIRA_PROJECT_KEY=SCRUM
JIRA_BOARD_ID=1
Copy from .env.example template:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
在此处获取你的 API 令牌:https://id.atlassian.com/manage-profile/security/api-tokens
使用跨平台运行器测试认证:
# 从 .claude/skills/jira 目录
node scripts/run.js test # 自动检测运行时
node scripts/run.js --python test # 强制使用 Python
node scripts/run.js --node test # 强制使用 Node.js
// 从环境变量加载(由 run.js 设置或手动设置)
const JIRA_EMAIL = process.env.JIRA_EMAIL;
const JIRA_API_TOKEN = process.env.JIRA_API_TOKEN;
const JIRA_BASE_URL = process.env.JIRA_BASE_URL;
const PROJECT_KEY = process.env.JIRA_PROJECT_KEY || 'SCRUM';
// 验证必需的环境变量
if (!JIRA_EMAIL || !JIRA_API_TOKEN || !JIRA_BASE_URL) {
console.error('Error: Missing required environment variables.');
process.exit(1);
}
// 构建认证请求头
const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_API_TOKEN}`).toString('base64');
const headers = {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
'Accept': 'application/json',
};
import base64
import os
import sys
from pathlib import Path
# 从父目录(jira 技能根目录)加载 .env 文件
def load_env():
env_path = Path(__file__).parent.parent / '.env'
if env_path.exists():
with open(env_path, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
os.environ.setdefault(key.strip(), value.strip())
load_env()
# 从环境变量获取配置
JIRA_EMAIL = os.environ.get('JIRA_EMAIL')
JIRA_API_TOKEN = os.environ.get('JIRA_API_TOKEN')
JIRA_BASE_URL = os.environ.get('JIRA_BASE_URL')
PROJECT_KEY = os.environ.get('JIRA_PROJECT_KEY', 'SCRUM')
# 验证必需的环境变量
if not all([JIRA_EMAIL, JIRA_API_TOKEN, JIRA_BASE_URL]):
print('Error: Missing required environment variables.', file=sys.stderr)
sys.exit(1)
# 构建认证请求头
auth_string = f'{JIRA_EMAIL}:{JIRA_API_TOKEN}'
auth_bytes = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8')
HEADERS = {
'Authorization': f'Basic {auth_bytes}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
function buildJiraAuthHeader(email: string, apiToken: string): string {
const credentials = Buffer.from(`${email}:${apiToken}`).toString('base64');
return `Basic ${credentials}`;
}
interface JiraConfig {
baseUrl: string;
email: string;
apiToken: string;
}
class JiraClient {
private baseUrl: string;
private headers: Record<string, string>;
constructor(config: JiraConfig) {
this.baseUrl = config.baseUrl.replace(/\/$/, '');
this.headers = {
'Authorization': buildJiraAuthHeader(config.email, config.apiToken),
'Accept': 'application/json',
'Content-Type': 'application/json',
};
}
async request<T>(path: string, options: RequestInit = {}): Promise<T> {
const url = `${this.baseUrl}/rest/api/3${path}`;
const response = await fetch(url, {
...options,
headers: { ...this.headers, ...options.headers },
});
if (response.status === 429) {
const resetTime = response.headers.get('X-RateLimit-Reset');
throw new Error(`Rate limited. Reset at: ${resetTime}`);
}
if (!response.ok) {
const error = await response.json().catch(() => ({}));
throw new Error(`Jira API error: ${response.status} - ${JSON.stringify(error)}`);
}
return response.json();
}
}
async function validateJiraConnection(client: JiraClient): Promise<boolean> {
try {
const user = await client.request<{ accountId: string; displayName: string }>('/myself');
console.log(`Connected as: ${user.displayName} (${user.accountId})`);
return true;
} catch (error) {
console.error('Jira connection failed:', error);
return false;
}
}
curl -X GET "https://mycompany.atlassian.net/rest/api/3/myself" \
-H "Authorization: Basic $(echo -n 'email@example.com:API_TOKEN' | base64)" \
-H "Accept: application/json"
{
"self": "https://mycompany.atlassian.net/rest/api/3/user?accountId=...",
"accountId": "5e10b8dbf0cab60d71f4a9cd",
"displayName": "John Doe",
"active": true,
"timeZone": "America/New_York"
}
| 指标 | 限制 |
|---|---|
| 已认证请求 | 60/分钟 |
| 未认证请求 | 20/分钟 |
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1640000000
async function withRateLimitRetry<T>(
fn: () => Promise<T>,
maxRetries = 3
): Promise<T> {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error: any) {
if (error.message.includes('Rate limited') && i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, 60000));
continue;
}
throw error;
}
}
throw new Error('Max retries exceeded');
}
https://)每周安装数
6
代码仓库
GitHub 星标数
3
首次出现
2026年2月20日
安全审计
安装于
opencode6
github-copilot6
codex6
kimi-cli6
gemini-cli6
cursor6
cp .env.example .env
# Edit .env with your credentials
Get your API token at: https://id.atlassian.com/manage-profile/security/api-tokens
Test authentication using the cross-platform runner:
# From .claude/skills/jira directory
node scripts/run.js test # Auto-detect runtime
node scripts/run.js --python test # Force Python
node scripts/run.js --node test # Force Node.js
// Load from environment variables (set by run.js or manually)
const JIRA_EMAIL = process.env.JIRA_EMAIL;
const JIRA_API_TOKEN = process.env.JIRA_API_TOKEN;
const JIRA_BASE_URL = process.env.JIRA_BASE_URL;
const PROJECT_KEY = process.env.JIRA_PROJECT_KEY || 'SCRUM';
// Validate required env vars
if (!JIRA_EMAIL || !JIRA_API_TOKEN || !JIRA_BASE_URL) {
console.error('Error: Missing required environment variables.');
process.exit(1);
}
// Build auth header
const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_API_TOKEN}`).toString('base64');
const headers = {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
'Accept': 'application/json',
};
import base64
import os
import sys
from pathlib import Path
# Load .env file from parent directory (jira skill root)
def load_env():
env_path = Path(__file__).parent.parent / '.env'
if env_path.exists():
with open(env_path, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
os.environ.setdefault(key.strip(), value.strip())
load_env()
# Configuration from environment variables
JIRA_EMAIL = os.environ.get('JIRA_EMAIL')
JIRA_API_TOKEN = os.environ.get('JIRA_API_TOKEN')
JIRA_BASE_URL = os.environ.get('JIRA_BASE_URL')
PROJECT_KEY = os.environ.get('JIRA_PROJECT_KEY', 'SCRUM')
# Validate required env vars
if not all([JIRA_EMAIL, JIRA_API_TOKEN, JIRA_BASE_URL]):
print('Error: Missing required environment variables.', file=sys.stderr)
sys.exit(1)
# Build auth header
auth_string = f'{JIRA_EMAIL}:{JIRA_API_TOKEN}'
auth_bytes = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8')
HEADERS = {
'Authorization': f'Basic {auth_bytes}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
function buildJiraAuthHeader(email: string, apiToken: string): string {
const credentials = Buffer.from(`${email}:${apiToken}`).toString('base64');
return `Basic ${credentials}`;
}
interface JiraConfig {
baseUrl: string;
email: string;
apiToken: string;
}
class JiraClient {
private baseUrl: string;
private headers: Record<string, string>;
constructor(config: JiraConfig) {
this.baseUrl = config.baseUrl.replace(/\/$/, '');
this.headers = {
'Authorization': buildJiraAuthHeader(config.email, config.apiToken),
'Accept': 'application/json',
'Content-Type': 'application/json',
};
}
async request<T>(path: string, options: RequestInit = {}): Promise<T> {
const url = `${this.baseUrl}/rest/api/3${path}`;
const response = await fetch(url, {
...options,
headers: { ...this.headers, ...options.headers },
});
if (response.status === 429) {
const resetTime = response.headers.get('X-RateLimit-Reset');
throw new Error(`Rate limited. Reset at: ${resetTime}`);
}
if (!response.ok) {
const error = await response.json().catch(() => ({}));
throw new Error(`Jira API error: ${response.status} - ${JSON.stringify(error)}`);
}
return response.json();
}
}
async function validateJiraConnection(client: JiraClient): Promise<boolean> {
try {
const user = await client.request<{ accountId: string; displayName: string }>('/myself');
console.log(`Connected as: ${user.displayName} (${user.accountId})`);
return true;
} catch (error) {
console.error('Jira connection failed:', error);
return false;
}
}
curl -X GET "https://mycompany.atlassian.net/rest/api/3/myself" \
-H "Authorization: Basic $(echo -n 'email@example.com:API_TOKEN' | base64)" \
-H "Accept: application/json"
{
"self": "https://mycompany.atlassian.net/rest/api/3/user?accountId=...",
"accountId": "5e10b8dbf0cab60d71f4a9cd",
"displayName": "John Doe",
"active": true,
"timeZone": "America/New_York"
}
| Metric | Limit |
|---|---|
| Authenticated requests | 60/minute |
| Unauthenticated requests | 20/minute |
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1640000000
async function withRateLimitRetry<T>(
fn: () => Promise<T>,
maxRetries = 3
): Promise<T> {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error: any) {
if (error.message.includes('Rate limited') && i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, 60000));
continue;
}
throw error;
}
}
throw new Error('Max retries exceeded');
}
https://)Weekly Installs
6
Repository
GitHub Stars
3
First Seen
Feb 20, 2026
Security Audits
Installed on
opencode6
github-copilot6
codex6
kimi-cli6
gemini-cli6
cursor6
AI新闻播客制作技能:实时新闻转对话式播客脚本与音频生成
1,200 周安装