新增了完整的Confluence集成插件,包含以下核心功能: 1. 基础认证与配置管理,支持API Token和OAuth2两种认证方式 2. 评论去重、权限控制与提及解析 3. 知识库检索与页面内容处理 4. 评论收发、编辑删除与流式回复支持 5. 附件与页面标签管理 6. 内容属性存储与AI元数据管理 7. Webhook事件接收与处理 8. 完整的插件配置与状态检查
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
import logging
|
|
|
|
import httpx
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
ATLASSIAN_TOKEN_URL = "https://auth.atlassian.com/oauth/token"
|
|
|
|
|
|
class ConfluenceOAuth2Flow:
|
|
@staticmethod
|
|
async def get_access_token(
|
|
client_id: str,
|
|
client_secret: str,
|
|
code: str,
|
|
redirect_uri: str,
|
|
) -> dict:
|
|
async with httpx.AsyncClient() as c:
|
|
resp = await c.post(
|
|
ATLASSIAN_TOKEN_URL,
|
|
json={
|
|
"grant_type": "authorization_code",
|
|
"client_id": client_id,
|
|
"client_secret": client_secret,
|
|
"code": code,
|
|
"redirect_uri": redirect_uri,
|
|
},
|
|
)
|
|
resp.raise_for_status()
|
|
return resp.json()
|
|
|
|
@staticmethod
|
|
async def refresh_token(
|
|
client_id: str,
|
|
client_secret: str,
|
|
refresh_token: str,
|
|
) -> dict:
|
|
async with httpx.AsyncClient() as c:
|
|
resp = await c.post(
|
|
ATLASSIAN_TOKEN_URL,
|
|
json={
|
|
"grant_type": "refresh_token",
|
|
"client_id": client_id,
|
|
"client_secret": client_secret,
|
|
"refresh_token": refresh_token,
|
|
},
|
|
)
|
|
resp.raise_for_status()
|
|
return resp.json()
|