AgnicPay

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.


Use an existing Agnic token without opening a browser:

npx agnic@latest --token <agnic_token> status

Or set an environment variable:

export AGNIC_TOKEN=<agnic_token>
npx agnic@latest status

--token takes precedence over AGNIC_TOKEN.


Browser OAuth Command

npx agnic@latest auth login

How It Works

  1. The CLI starts a temporary local server on a random port
  2. Opens your default browser to AgnicPay's OAuth consent screen
  3. You sign in (email, Google, or wallet) and approve spending limits
  4. The browser redirects back to http://localhost:<port>/callback
  5. 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:

npx agnic@latest status

Expected output when authenticated:

Wallet Status
Authenticated

Email:    [email protected]
Wallet:   0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7
Expires:  2026-05-22 14:30:00 UTC

Logout

To remove stored credentials:

npx agnic@latest auth logout

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

ErrorSolution
"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

Next Steps

On this page