Authentication
Spark CLI supports multiple authentication methods. Choose the one that fits your workflow.
OAuth login (recommended)
spark loginThis opens your browser for an OAuth 2.0 PKCE flow. After you authorize, an access token and refresh token are written to ~/.spark/settings.json (mode 0o600). Tokens refresh automatically with a 5-minute buffer before expiration.
This is the recommended method for local development.
All authentication methods
spark loginOpens your default browser. Completes an OAuth 2.0 PKCE flow and writes tokens to ~/.spark/settings.json. Tokens refresh automatically.
Creating an API key
- Go to spark.memco.ai/dashboard (opens in a new tab)
- Navigate to Settings > API Keys
- Click Create Key, give it a name, and copy the value
- Store the key securely — it is shown only once
Credential priority order
When multiple credentials are present, Spark uses this priority:
| Priority | Method | Use case |
|---|---|---|
| 1 (highest) | --api-key global flag | One-off commands |
| 2 | SPARK_API_KEY env var | CI/CD pipelines |
| 3 | OAuth tokens (~/.spark/settings.json or ./.spark/settings.json) | Local development |
| 4 (lowest) | Legacy API key in settings.json | Backward compatibility |
If a higher-priority credential is present, lower-priority credentials are ignored.
Where credentials live
| Path | Set by | Scope |
|---|---|---|
~/.spark/settings.json | spark login (default) | All projects for the current user |
./.spark/settings.json | spark login --local | Current project only |
Both files are created with 0o600 permissions (owner read/write). Credentials are keyed by API base URL inside the file, so multiple Spark instances (e.g. self-hosted) coexist cleanly.
Security
- All API traffic uses HTTPS only. Spark CLI refuses to send credentials over plain HTTP.
- Credential files are created with 0o600 permissions (owner read/write only).
- API keys can be revoked immediately from the dashboard.
Verify authentication
spark whoamiA successful output shows your authenticated identity. For a fuller picture (version, IDE skills, organization), use:
spark statusNext steps
Now that you are authenticated, run your first query.