If you’re new to Events Reporting, learn how to get started with 1Password Events API.
Requirements
Before implementing any of the examples, or your own scripts, you’ll need to generate a bearer token and store it in your 1Password account. To get a bearer token, you can:- Set up a new Events Reporting integration.
- Issue a new token in an existing integration.
- Generate a token with 1Password CLI.
Usage
All scripts use theEVENTS_API_TOKEN environment variable to load your API token.
We recommend setting EVENTS_API_TOKEN to a secret reference that points to where your bearer token is saved in 1Password, to avoid revealing the token in plaintext. Then you can use op run with 1Password CLI to securely provision the token at runtime.
Learn more about securely loading secrets from the environment.
For example, to set the EVENTS_API_TOKEN environment variable with an environment file, then use op run to run the PHP eventsapi.php script with the variable provisioned:
events.env
EVENTS_API_TOKEN environment variable, then use op run to run the Go eventsapi.go script with the variable provisioned:
- bash, sh, zsh, fish
- Powershell