Manage API tokens for service accounts

You can use an API token to authenticate a script with an Atlassian cloud app. You generate the token for your service account, then copy and paste it into a script.

認証に 2 段階認証を使用する場合、スクリプトでは REST API トークンによって認証する必要があります。

What is an API token?

A primary use case for API tokens is to allow scripts to access REST APIs for Atlassian cloud apps using HTTP basic authentication.

使用する HTTP ライブラリの詳細によっては、パスワードをトークンで置き換えることができます。たとえば、curl を使用している場合、以下のようにします。

## URLs for API tokens with scopes for Jira and Confluence curl -v https://api.atlassian.com/ex/jira/{cloudId} --user bot@serviceaccount.atlassian.com:my-api-token curl -v https://api.atlassian.com/ex/confluence/{cloudId} --user bot@serviceaccount.atlassian.com:my-api-token

この例では、bot@serviceaccount.atlassian.com はトークンの作成に使用した Atlassian アカウントのメール アドレスです。

We use varied API token length rather than fixed length to ensure tokens are secure and reliable. If your script relies on a fixed API token length, check that it can handle a variable length.

API トークンのスコープとは

API tokens for service accounts use scopes by default. The scope for an API token defines the levels of access to data in your Atlassian apps. When you create an API token, you choose the access level for the API token. When you select scopes for the token, you give the token permissions to perform certain actions. You can only select scopes for Jira and Confluence.

You can allow APIs to view, write, and delete content in Jira and Confluence.

Jira のスコープに移動する

Confluence のスコープに移動する

How to access the API

You need to use a base URL to make API requests: api.atlassian.com. Then you can construct a request to call the API for the app you’d like to access.

スコープ付き API トークンを作成する

API tokens with an infinite lifespan pose a data security risk. To improve data security, by default, we set API tokens to expire in one year. When you create an API token, you can name it and set the expiration date for the token.

サービス アカウントの API トークンを作成すると、サービス アカウントは認証を行い、アクセス権を付与したアプリのスクリプトを実行できるようになります。トークンを作成する際には、トークンのスコープを選択する必要があります。

To create an API token for a service account:

  1. admin.atlassian.com に移動します。 複数の組織がある場合は、対象の組織を選択します。

  2. [ディレクトリ] > [サービス アカウント] の順に選択します。

  3. For the service account, select Actions > Create credential.

  4. API トークンには、その機能を説明する名前を付けてください。

  5. API トークンの有効期限を選択します。

    1. トークンの有効期限は 1 〜 365 日です。

  6. API トークンでアクセスするアプリを選択します。

  7. スコープを選択して、API トークンが Jira または Confluence で実行できることを決定します。

  8. [作成] を選択します。

  9. [クリップボードにコピー] を選択してから、スクリプトにトークンを貼り付けるか、安全な場所に保存します。

You can't recover the API token after you’re done with this step. We recommend you save these best practices to keep your token safe:

  • API トークンをパスワード マネージャーに保存する。

サービス アカウントのトークンを作成する前に、サービス アカウントを作成する必要があります。

API トークンを取り消す

When you revoke a token it no longer works and we permanently remove it from your account. If you revoke an existing API token, you can replace it with a new token. It takes up to 10 minutes for the token to be revoked.

API トークンを取り消すには、次の手順に従います。

  1. admin.atlassian.com に移動します。 複数の組織がある場合は、対象の組織を選択します。

  2. [ディレクトリ] > [サービス アカウント] の順に選択します。

  3. For the service account, select Revoke.

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。