> For the complete documentation index, see [llms.txt](https://manual.dxable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.dxable.com/1password/generic-scripts.md).

# 1Password イベント API 汎用スクリプト

イベントレポートを初めて使う場合は、[1Password イベントレポートの使用開始方法を学んでください](https://support.1password.com/events-reporting/)。

Events API を使い始める際に役立つように、[JavaScript](https://github.com/1Password/events-api-generic/blob/main/eventsapi.js)、[Python](https://github.com/1Password/events-api-generic/blob/main/eventsapi.py)、[Ruby](https://github.com/1Password/events-api-generic/blob/main/eventsapi.rb)、[Go](https://github.com/1Password/events-api-generic/blob/main/eventsapi.go)、[PHP](https://github.com/1Password/events-api-generic/blob/main/eventsapi.php)など、複数の言語の[サンプル スクリプトのリポジトリ](https://github.com/1Password/events-api-generic)を用意しました。スクリプトは、過去 24 時間のサインイン試行とアイテム使用イベ​​ントを最大 20 件出力します。

### 必要条件 <a href="#id-3p9ivrxkea6g" id="id-3p9ivrxkea6g"></a>

いずれかの例または独自のスクリプトを実装する前に、ベアラー トークンを生Createして 1Password アカウントにSaveする必要があります。

bearer トークンを発行するには:

* ①1Password.com のアカウントに[サインイン](https://start.1password.com/signin)し、サイドバーの[「開発者ツール」](https://start.1password.com/developer-tools/active)をクリックします。
* ②トークンを発行するイベント レポート統合を選択し、**Add a token**をクリックします。
* ③ベアラー トークンの名前を入力し、有効期限を選択します。トークンがアクセスできるイベント タイプを選択または選択解除し、**Issue Token**をクリックします。
* ④**Save in 1Password**をクリックし、トークンをSaveする保管庫を選択します。次に、**View Integration Details**をクリックします。

[コマンドライン ツール](https://developer.1password.com/docs/cli/reference/management-commands/events-api/#events-api-create)を使用して API ベアラー トークンを生Createすることもできます。

### [**使用方法**](https://developer.1password.com/docs/events-api/generic-scripts/#usage) <a href="#unn1bg8ysok7" id="unn1bg8ysok7"></a>

**全ての**スクリプトはEVENTS\_API\_TOKEN環境変数を使用して API トークンを読み込みます。

トークンがプレーンテキストで公開されるのを避けるために、ベアラー トークンが 1PasswordにSaveされている場所を指す[秘密の参照](https://developer.1password.com/docs/cli/secret-reference-syntax/)EVENTS\_API\_TOKENを設定することをお勧めします。その後、実行時にトークンを安全にプロビジョニングするために[op run](https://developer.1password.com/docs/cli/reference/commands/run/)を使用できます。

[環境からシークレットを安全に読み込む方法について詳しく紹介します。](https://developer.1password.com/docs/cli/secrets-environment-variables/)

例えば、環境ファイルで [EVENTS\_API\_TOKEN環境変数](https://developer.1password.com/docs/cli/secrets-environment-variables/#use-environment-env-files)を設定するには、[op run](https://developer.1password.com/docs/cli/reference/commands/run/)を使用して、プロビジョニングされた変数で PHP eventsapi.php スクリプトを実行します。

events.env

$ EVENTS\_API\_TOKEN="op\://Vault/Item/token"

op run --env-file="./events.env" -- php eventsapi.php

[EVENTS\_API\_TOKEN環境変数](https://developer.1password.com/docs/cli/secrets-environment-variables/#export-environment-variables)をエクスポートするには、[op run](https://developer.1password.com/docs/cli/reference/commands/run/)を使用して、プロビジョニングされた変数で Go eventsapi.go スクリプトを実行します。

**bash, sh, zsh, fish**

$ EVENTS\_API\_TOKEN="op\://Vault/Item/token" op run -- go run eventsapi.go

**Powershell**

* **①Export the necessary environment variables:**
* **$Env:EVENTS\_API\_TOKEN = "op\://Vault/Item/token"**
* **②Run op run -- with your command for starting the app:**
* **op run -- go run eventsapi.go**

### **Learn more** <a href="#q8eor519fdo4" id="q8eor519fdo4"></a>

* [1Passwordイベントレポートを使い始める](https://support.1password.com/events-reporting/)
* [1Passwordについて イベント セキュリティの報告](https://support.1password.com/events-reporting-security/)
* [イベントレポートAPIベアラートークンの発行または取り消し](https://support.1password.com/events-reporting/#appendix-issue-or-revoke-bearer-tokens)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.dxable.com/1password/generic-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
