Authenticate
Authenticate to AgnicPay wallet using browser OAuth or non-browser API token mode
Authenticate
Authenticate to AgnicPay wallet using either browser OAuth or token mode for headless agents. This skill handles authentication, session management, and token storage.
Non-Browser Token Mode (Recommended for Agents)
Use an existing Agnic token without opening a browser:
Or set an environment variable:
--token takes precedence over AGNIC_TOKEN.
Browser OAuth Command
How It Works
- The CLI starts a temporary local server on a random port
- Opens your default browser to AgnicPay's OAuth consent screen
- You sign in (email, Google, or wallet) and approve spending limits
- The browser redirects back to
http://localhost:<port>/callback - The CLI exchanges the authorization code for tokens and saves them locally
Wait for the CLI to print Authenticated! before proceeding.
Check Status
Before authenticating, check if a session is already active:
Expected output when authenticated:
Logout
To remove stored credentials:
Token Storage
Credentials are stored in ~/.agnic/config.json with restricted permissions (0600). Tokens auto-refresh on 401 responses — no manual re-authentication needed until the refresh token expires (90 days).
Error Handling
| Error | Solution |
|---|---|
| "Not authenticated" | Provide --token, set AGNIC_TOKEN, or run npx agnic@latest auth login |
| "Authentication failed" | User cancelled the browser flow or the timeout (5 min) expired |
| "Could not open browser" | The CLI prints a URL to copy and open manually |
| "Invalid or revoked token" | Token is incorrect, revoked, or expired; rotate and retry |
| "Token expired" | Tokens auto-refresh; if refresh also fails, re-run npx agnic@latest auth login |