Anexus Auth Codes SDK — one-time verification codes for AI agents
Project description
Anexus Python SDK
One login. One-time verification codes. Your AI acts on your behalf.
Two packages, two purposes:
pip install anexus-sdk # For users & AI agents
pip install anexus-verify # For platform developers (verifying codes)
Table of Contents
- For End Users (Human)
- For AI Agents
- For Platform Developers
- API Reference
- CLI Commands
- Troubleshooting
- Architecture
For End Users (Human)
No API keys, no configuration. Just install and login once.
Install
pip install anexus-sdk
Login (one-time)
python -m anexus_sdk login
This opens your browser. Sign in, and the session token is saved automatically to ~/.anexus/token. The flow is identical to GitHub Copilot's device authorization.
Check login status
python -m anexus_sdk whoami
Done
Now your AI can generate verification codes and act on your behalf. You don't need to do anything else.
For AI Agents
As an AI, you import the SDK to check if the human is still logged in and to generate verification codes.
1. Check if the human is logged in
from anexus_sdk import check_login
status = check_login()
if not status["logged_in"]:
# Human needs to run `python -m anexus_sdk login`
print(f"Session expired: {status['error']}")
return
print(f"Logged in as {status['username']}")
2. Request a verification code
from anexus_sdk import generate_code
result = generate_code("shopify")
# {
# "success": True,
# "code": "anx://shopify/user_abc123?exp=3600&ts=1717000000",
# "target": "shopify",
# "expires_in": "1 hour",
# "geo_location": "CN/GD"
# }
code = result["code"]
3. Use the code to call the target platform
Pass the verification code to the target platform's API or MCP server.
# Example: calling Shopify's API with the auth code
response = call_shopify_api(
auth_code=code, # "anx://shopify/user_abc123?exp=3600&ts=..."
action="get_orders",
)
The platform will verify the code with Anexus before granting access.
For Platform Developers
You run a platform (Shopify, Notion, Slack, etc.) that wants to accept Anexus auth codes from users' AI agents.
How it works
User's AI → sends anx://shopify/user_abc123?... → your platform
→ your platform calls Anexus verify API
→ Anexus returns verified user identity
→ you grant access
1. Get your API Key
- Register on the Anexus Dashboard
- Go to Platform Integration section
- Click Create API Key
- Your key:
nxs6_xxxxxxxxxxxx
2. Install the verify package
pip install anexus-verify
This package contains exactly one function — verify_code(). That's all you need.
3. Verify incoming auth codes
from anexus_verify import verify_code
def handle_ai_request(auth_code_from_ai):
"""
Called when a user's AI presents an Anexus auth code.
"""
result = verify_code(
code=auth_code_from_ai,
api_key="nxs6_xxxxxxxxxxxx",
)
if not result["verified"]:
return {"error": "Invalid auth code"}
# You now know exactly who this user is
username = result["username"]
user_id = result["user_id"]
target = result["target_platform"]
permissions = result["permissions"]
return {"access": "granted", "user": username, "can": permissions}
4. (Optional) HMAC signing for extra security
result = verify_code(
code=auth_code_from_ai,
api_key="nxs6_xxxxxxxxxxxx",
api_secret="your-api-secret",
)
This adds an HMAC-SHA256 signature that the server validates.
5. Response format
Success:
{
"verified": true,
"username": "alice",
"user_id": "user_abc123",
"name": "Alice Wang",
"target_platform": "shopify",
"identity_type": "human",
"permissions": ["read_orders", "manage_products"],
"geo_location": "CN/GD"
}
Failure:
{
"verified": false,
"error": "Code expired or already used"
}
6. Integration checklist
- Register on Anexus Dashboard
- Create an API Key
- Install
anexus-verify - When receiving auth codes from AIs, call
verify_code()before granting access - Handle
verified: falsegracefully (return error to AI) - (Optional) Store the API Secret for HMAC signing
API Reference
check_login(session_token=None, base_url=None)
Check if the current session is valid. For AI agents.
status = check_login()
# Returns:
# {
# "logged_in": True,
# "user_id": "user_abc123",
# "username": "alice",
# "email": "alice@example.com",
# "role": "human"
# }
| Param | Type | Default | Description |
|---|---|---|---|
session_token |
str |
None |
Session token (reads from ~/.anexus/token if not provided) |
base_url |
str |
ANEXUS_BASE_URL env or http://localhost:8000 |
API base URL |
generate_code(target, session_token=None, base_url=None)
Request a verification code. For AI agents acting on behalf of a human.
result = generate_code("shopify")
code = result["code"] # "anx://shopify/user_abc123?exp=3600&ts=..."
| Param | Type | Default | Description |
|---|---|---|---|
target |
str |
required | Platform name (e.g. shopify, notion, slack) |
session_token |
str |
None |
Session token (reads from ~/.anexus/token if not provided) |
base_url |
str |
ANEXUS_BASE_URL env or http://localhost:8000 |
API base URL |
Returns:
{
"success": true,
"code": "anx://shopify/user_abc123?exp=3600&ts=1717000000",
"target": "shopify",
"expires_in": "1 hour",
"geo_location": "CN/GD"
}
verify_code(code, api_key, api_secret=None, base_url=None)
Verify an auth code received from a user's AI. For platform developers.
result = verify_code(
code="anx://shopify/user_abc123?exp=3600&ts=1717000000",
api_key="nxs6_xxxxxxxxxxxx",
)
| Param | Type | Default | Description |
|---|---|---|---|
code |
str |
required | The auth code from the AI |
api_key |
str |
required | Your API Key from Dashboard |
api_secret |
str |
None |
HMAC signing key (optional) |
base_url |
str |
ANEXUS_BASE_URL env or http://localhost:8000 |
API base URL |
Full examples in examples/.
CLI Commands
| Command | Description | For |
|---|---|---|
python -m anexus_sdk login |
Browser-based login | End users |
python -m anexus_sdk whoami |
Check login status | End users |
python -m anexus_sdk status |
Alias for whoami | End users |
python -m anexus_sdk code <platform> |
Generate verification code | AI agents |
Troubleshooting
"Not logged in" error
python -m anexus_sdk login
This opens your browser. Complete the sign-in flow.
"Network error"
Check that the Anexus server is running and accessible:
curl http://localhost:8000/api/v1/session/check
"Code expired"
Auth codes are one-time use and expire after 1 hour. Generate a new code:
from anexus_sdk import generate_code
code = generate_code("shopify")["code"]
ImportError: no module named anexus_verify
Make sure you installed the correct package:
pip install anexus-verify
Architecture
┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
│ End User │ │ AI Agent │ │ Platform │
│ │ │ │ │ (Shopify/etc) │
│ pip install │ │ from anexus_sdk │ │ │
│ anexus-sdk │ │ import generate_code│ │ pip install │
│ │ │ │ import check_login │ │ anexus-verify │
│ ▼ │ │ │ │ │ │
│ browser login ──────┼─────► check_login() │ │ from anexus_verify │
│ │ │ │ │ │ │ import verify_code │
│ │ │ │ generate_code() ────┼─────► │
│ │ │ │ ("shopify") │ │ │ │
│ │ │ │ │ │ │ ▼ │
│ │ │ │ code ───────────────┼─────► verify_code() ──────┼──► Anexus API
│ │ │ │ │ │ │ │
│ │ │ │ │ │ grants access │
└──────────────────────┘ └──────────────────────┘ └──────────────────────┘
anexus-sdk anexus-sdk anexus-verify
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anexus_sdk-0.3.0.tar.gz.
File metadata
- Download URL: anexus_sdk-0.3.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdc991015dccbf581431ac42438a983600e546b0b55aa10dd69b810324c9c369
|
|
| MD5 |
94e897155c14e5fc0ef27f2c2fd0654c
|
|
| BLAKE2b-256 |
264888039ac05207f4040c7f71537968cae3d1fdc77a5a7bd7015a9593ae413a
|
File details
Details for the file anexus_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: anexus_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79ca37a7a22e8b956140fb9dbea12f9f9777a7fa81ac020737aeed6b5326c891
|
|
| MD5 |
64968ef118771441e0f661e0a9425c7f
|
|
| BLAKE2b-256 |
f1318c12c9dbc4a03e98ccf78ef6a82d6a721f8bfc6557b7751b6858bfdcc2d7
|