What is AgentSecrets?
The Zero-Knowledge Difference
How AgentSecrets Works
Installation
Quick Start
Migrating from .env Files
Migrating from Vault / AWS
Migrating from dotenv-vault
Production Checklist
Credential Exposure
What Zero-Knowledge Means
The Proxy Model
The Three-Layer Model
Environments
Agent Identity
Storage Modes
The No get() Principle
Secret-Level Policies
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API Reference
Account (init / login)
Server & Self-Hosting (server)
Docs
Shell Autocompletion
Keychain Auth
Secrets
Environments
Credential Proxy
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
Integrations Overview
Claude Desktop
Cursor
OpenClaw
HTTP Proxy (Any)
LangChain (Soon)
CrewAI (Soon)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
Ecosystem Overview
Zero-Knowledge MCP Server
Server Overview
5-Layer Architecture
Self-Hosting Guide
Authentication & Keys
Workspaces & Teams
Projects & Scope
Environments
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint Reference
Security Overview
Anti-Impersonation & Process Verification
Encryption Model
Zero-Knowledge Sync
Proxy Security Layers
Threat Model
OWASP Top 10 Mitigation
Security FAQ
Third-Party Audit
Reporting Vulnerabilities
Guides Overview
Building on the SDK
Stripe Integration
OpenAI Integration
Multi-Agent Setup
Onboarding Team
CI/CD Pipeline
Publishing ZK MCP
Rotating Credentials
Auditing Team Activity
Dev to Production
Kubernetes Deployment
Monorepo Setup
Production Proxy Hardening
vs .env Files
vs HashiCorp Vault
vs AWS Secrets Manager
vs dotenv-vault
vs Infisical
When Not to Use
Proxy Not Starting
Proxy Not Resolving
Domain Blocked
Sync Conflicts
MCP Not Connecting
Session Token Errors
Proxy Session Authorization
Keychain Storage & Backends
SSRF & Destination Rules
Installation Issues
Error Codes Reference
Frequently Asked Questions
v3.1.x
v3.0.0
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
TroubleshootingProxy Session Authorization

Troubleshooting Local Proxy Session Token Errors

If you receive 401 Unauthorized responses from the local proxy engine at http://localhost:8765/proxy or endpoints like /approve, /sync, or /rotate-session, your client is failing pre-shared session token validation.


Understanding Local Proxy Sessions

To prevent unauthorized scripts, browser tabs, or process-escaped programs on your host machine from accessing the local credential proxy, the AgentSecrets daemon gates access using a pre-shared session token.

  • Lifecycle: A new session token is generated every time the proxy daemon starts (via agentsecrets proxy start or transient execution).
  • Storage: The session token is stored securely in the native OS Keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service). No plaintext token files exist on disk.
  • Auto-Injection: The agentsecrets CLI client and built-in MCP server automatically retrieve this token and inject it via the X-AS-Session-Token HTTP header, making proxy operations completely seamless.

Diagnose and Fix

If you are using third-party clients, custom libraries, or experiencing connectivity issues, follow these steps to resolve token mismatch errors:

1Restart the Proxy Daemon

Restarting the daemon clears out stale processes and writes a fresh, valid session token to the secure local keychain. Run:

agentsecrets proxy stop agentsecrets proxy start

2Verify Client-Side Injection

If you are calling the proxy from custom HTTP scripts (e.g., in Node.js or Python) rather than the CLI client, you must read the pre-shared key from the OS Keychain and set it in your headers.

  • Header Name: X-AS-Session-Token
  • Command to Read: Use the CLI to safely print the active token:
    agentsecrets proxy rotate-session
    (Note: This rotates the token and returns the active string, which you can load into your custom client context.)

3Check OS Keychain Availability

If the OS Keychain is locked or inaccessible (e.g. running in a headless SSH session without a configured D-Bus), the proxy cannot retrieve the session token.

  • Verify your keychain status by running:
    agentsecrets status
  • If running on headless Linux, ensure dbus-run-session is configured or that keychain-auth fallback files are writable.
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.