闲社服务运行正常AI智能体自动化平台
a

AINative认证指南

技能标识:ainative-auth-guide

Implement authentication for AINative APIs. Use when (1) Choosing between API key and JWT auth, (2) Registering/logging in users, (3) Refreshing tokens, (4) Implementing OAuth2 (LinkedIn/GitHub), (5) Using API keys for server-side or agent use. Covers email/password, OAuth2 social login, API key management, and middleware patterns. Closes #1519.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

AINative认证指南

AINative 身份验证指南

身份验证方法

方法使用场景请求头
API 密钥服务端、代理、SDK、MCP 工具X-API-Key: ak_...
Bearer JWT
用户会话、Web 应用 | Authorization: Bearer | | OAuth2 | 社交登录(LinkedIn、GitHub) | 标准 OAuth2 流程 |

API 密钥身份验证(最简单)

通过 npx zerodb init 或从控制台获取密钥。

python
import requests

response = requests.get(
https://api.ainative.studio/api/v1/public/credits/balance,
headers={X-API-Key: akyourkey}
)

typescript
const res = await fetch(https://api.ainative.studio/api/v1/public/credits/balance, {
headers: { X-API-Key: akyourkey }
});

邮箱/密码注册与登录

python

注册


resp = requests.post(
https://api.ainative.studio/api/v1/auth/register,
json={email: user@example.com, password: securepass, name: Alice}
)
token = resp.json()[access_token]

登录

resp = requests.post( https://api.ainative.studio/api/v1/auth/login, json={email: user@example.com, password: securepass} ) accesstoken = resp.json()[accesstoken] refreshtoken = resp.json()[refreshtoken]

JWT 使用

python
headers = {Authorization: fBearer {access_token}}
me = requests.get(https://api.ainative.studio/api/v1/users/me, headers=headers).json()

令牌刷新

python
resp = requests.post(
https://api.ainative.studio/api/v1/auth/refresh,
json={refreshtoken: refreshtoken}
)
newaccesstoken = resp.json()[access_token]

退出登录

python
requests.post(
https://api.ainative.studio/api/v1/auth/logout,
headers={Authorization: fBearer {access_token}}
)

OAuth2 社交登录

python

LinkedIn


resp = requests.post(
https://api.ainative.studio/api/v1/auth/linkedin/callback,
json={code: oauthcode, redirecturi: https://yourapp.com/callback}
)

GitHub

resp = requests.post( https://api.ainative.studio/api/v1/auth/github/callback, json={code: oauthcode, redirecturi: https://yourapp.com/callback} ) token = resp.json()[access_token]

Next.js 中间件

typescript
// middleware.ts
import { createMiddleware } from @ainative/next-sdk/middleware;

export const middleware = createMiddleware({
apiKey: process.env.AINATIVEAPIKEY!,
protectedPaths: [/dashboard, /api/protected],
loginPath: /login,
});

密码重置

python

请求重置邮件


requests.post(https://api.ainative.studio/api/v1/auth/forgot-password,
json={email: user@example.com})

使用邮件中的令牌设置新密码

requests.post(https://api.ainative.studio/api/v1/auth/reset-password, json={token: resettokenfromemail, newpassword: newpassword})

身份验证端点

端点方法描述
/api/v1/auth/registerPOST创建账户
/api/v1/auth/login
POST | 邮箱/密码 → JWT | | /api/v1/auth/logout | POST | 使会话失效 | | /api/v1/auth/refresh | POST | 刷新访问令牌 | | /api/v1/users/me | GET | 当前用户信息 | | /api/v1/auth/verify-email | POST | 验证邮箱地址 | | /api/v1/auth/forgot-password | POST | 发送重置邮件 | | /api/v1/auth/reset-password | POST | 应用新密码 | | /api/v1/auth/linkedin/callback | POST | LinkedIn OAuth2 | | /api/v1/auth/github/callback | POST | GitHub OAuth2 |

错误码

状态码含义
401令牌或密钥无效/缺失
403
身份验证有效,但权限不足 | | 409 | 邮箱已注册 |

参考

  • - src/backend/app/api/v1/endpoints/auth.py — 身份验证端点实现
  • packages/sdks/nextjs/src/middleware/ — Next.js 身份验证中间件
  • docs/guides/AUTHENTICATION.md — 完整身份验证指南

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 ainative-auth-guide-1776064696 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 ainative-auth-guide-1776064696 技能

通过命令行安装

skillhub install ainative-auth-guide-1776064696

下载

⬇ 下载 ainative-auth-guide v1.0.0(免费)

文件大小: 2.18 KB | 发布时间: 2026-4-14 14:38

v1.0.0 最新 2026-4-14 14:38
- Initial release of the ainative-auth-guide skill.
- Provides comprehensive authentication guidance for AINative APIs, including API key, JWT, email/password, OAuth2 (LinkedIn/GitHub), and middleware patterns.
- Includes usage examples for Python and TypeScript, with step-by-step registration, login, token management, and social login flows.
- Lists main authentication endpoints, error codes, and reference links for further documentation.
返回顶部