---
schema_version: "1"
id: d160afbaac363fd8d7347adc04a5a1bab6cfe1fe9e396db1019f2a59f3e9ff6d
title: Anypoint Platform CLI に対する認証
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/anypoint-cli/latest/auth.md
canonical_url: https://docs.mulesoft.com/jp/anypoint-cli/latest/auth
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9f30289579f54731b9b80af079406b797e50eb37f0ef3d1f03f1d0fa5adb3be5
description: MuleSoft Documentation Site
release: 4.x
latest: true
---
# Anypoint Platform CLI に対する認証

Anypoint CLI に対して認証するには、認証オプションの組み合わせのいずれかを使用する必要があります。

- ユーザー名とパスワード
- クライアント ID とクライアントシークレット
- ベアラートークン (コマンドラインのみ)

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">2022 年 10 月以降、すべてのユーザーに対する多要素認証 (MFA) の有効化の一環として、Anypoint CLI を使用する方法は​<a href="https://docs.mulesoft.com/jp/access-management/connected-apps-overview" class="xref page">接続アプリケーション</a>​経由のみになります。</td></tr></tbody></table>

指定しない場合、デフォルトのホスト、環境、および組織が使用されます。

次の方法を使用して、Anypoint CLI ログイン情報を渡します。

- [ログイン情報設定ファイルの使用](#credentials-file)
- [コマンドラインパラメーターの使用](#command-line-parameters)
- [環境変数の使用](#env-variables)

設定は次のように上書きされます。

- コマンドラインパラメーターはその他すべての方法を上書きする。
- コマンドラインパラメーターが指定されていない場合は環境変数が使用され、ログイン情報設定ファイルの設定を上書きする。
- コマンドラインパラメーターまたは環境変数が設定されていない場合、ログイン情報設定ファイルのパラメーターが使用される。

## [](#credentials-file)Conf コマンドを使用してログイン情報を設定する

`conf`​ オプションを指定して ​`anypoint-cli-v4`​ コマンドを実行し、ログイン情報を設定ファイルに追加してから、使用する ​`anypoint-cli-v4`​ コマンドを実行することで、Anypoint Platform に対して認証できます。次のパラメーターの組み合わせを使用して、設定ファイルに認証値を設定できます。

username
password
client\_id
client\_secret
host
session.selectedEnvironment.id
session.selectedOrganization.id

設定ファイルを作成するには、次の操作を実行します。

- 認証方法の設定に使用するパラメーターを指定して、​`anypoint-cli-v4 conf`​ コマンドを実行する。たとえば、次のコマンドはユーザー名とパスワードを設定します。
    
    $ anypoint-cli-v4 conf username <username>
    $ anypoint-cli-v4 conf password <password>

このコマンドは、次の場所にある ​`config.json`​ ファイルにログイン情報を保存します。

- MacOS: `~/Library/Preferences/@mulesoft/anypoint-cli-v4-nodejs/config.json`
- Windows: `%APPDATA%\anypoint-cli-v4-nodejs\Config`
- Unix: `~/.config/anypoint-cli-v4-nodejs/`

**例:**

- ユーザー名とパスワードを使用して設定ファイル認証を設定する
    
    - 次のコマンドを使用して、設定ファイルに認証値を追加します。
        
        $ anypoint-cli-v4 conf username myUserName
        $ anypoint-cli-v4 conf password myPassword
        $ anypoint-cli-v4 conf organization myOrgId
    - コマンドを実行すると、設定ファイルの値を使用して認証が行われます。
        
        $ anypoint-cli-v4 account:environment:list
- クライアント ID とクライアントシークレットを使用して設定ファイル認証を設定する
    
    - 次のコマンドを使用して、設定ファイルに認証値を追加します。
        
        $ anypoint-cli-v4 conf client\_id myClientID
        $ anypoint-cli-v4 conf client\_secret myCLientSecret
        $ anypoint-cli-v4 conf organization myOrgId
    - コマンドを実行すると、設定ファイルの値を使用して認証が行われます。
        
        $ anypoint-cli-v4 account:environment:list
        
        `organization`​ フラグは省略可能です。デフォルトでは、Anypoint Platform のメイン組織に設定されます。

<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p><code>client_id</code>​ と ​<code>client_secret</code>​ は接続アプリケーション経由で取得できます。詳細は、​<a href="https://docs.mulesoft.com/jp/access-management/connected-apps-developers" class="xref page">「開発者向けの接続アプリケーション」</a>​を参照してください。</p>
</div>
<div class="paragraph">
<p>接続アプリケーションでは、Anypoint Platform に対する認証を行うために ​<code>[View Organization (組織の表示)]</code>​ スコープと ​<code>[View Environment (環境の表示)]</code>​ スコープが必要です。</p>
</div>
</td>
</tr>
</tbody></table>

## [](#command-line-parameters)コマンドラインパラメーター

次のパラメーターの組み合わせを使用して ​`anypoint-cli-v4`​ コマンドを実行することで、コマンドラインから Anypoint Platform に対して認証できます。

\--username
--password
--client\_id
--client\_secret
--bearer
--organization
--environment

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content"><code>--organization</code>​ フラグは省略可能です。デフォルトでは、Anypoint Platform のメイン組織に設定されます。 <strong>例:</strong></td></tr></tbody></table>

- ユーザー名とパスワードを使用してコマンドラインで認証する
    
    $ anypoint-cli-v4 account:environment:list --username myUserName --password myPassword --organization myOrgId
- クライアント ID とクライアントシークレットを使用してコマンドラインで認証する
    
    $ anypoint-cli-v4 account:environment:list --client\_id myClientID --client\_secret myClientSecret --organization myOrgId
- ベアラートークンを使用してコマンドラインで認証する
    
    Anypoint Platform でベアラートークンを生成し、Anypoint CLI に直接渡すことができます。ベアラートークンを提供した場合、Anypoint CLI は他に提供されているすべてのユーザーログイン情報やクライアントログイン情報を無視します。
    
    $ anypoint-cli-v4 account:environment:list --bearer myBearerToken --organization myOrgId
    
    ベアラートークンの有効期限が切れると、Anypoint Platform セッションの有効期限が切れます。
    
    ベアラートークンの生成については、 [「How to Generate Your Authorization Bearer Token for Anypoint Platform (Anypoint Platform 用の認証ベアラートークンの生成方法)」](https://help.mulesoft.com/s/article/How-to-generate-your-Authorization-Bearer-token-for-Anypoint-Platform)​を参照してください。

## [](#env-variables)環境変数

`anypoint-cli-v4`​ コマンドを実行する前に、次の環境変数の組み合わせを設定することで、Anypoint Platform に対して認証できます。

ANYPOINT\_USERNAME
ANYPOINT\_PASSWORD
ANYPOINT\_CLIENT\_ID
ANYPOINT\_CLIENT\_SECRET
ANYPOINT\_ORG
ANYPOINT\_ENV
ANYPOINT\_HOST
ANYPOINT\_CERTIFICATE

**例:**

- ユーザー名とパスワードの環境変数を設定して認証する
    
    $ export ANYPOINT\_USERNAME=myUserName
    $ export ANYPOINT\_PASSWORD=myPassword
    $ export ANYPOINT\_ORG=myOrgId
    $ anypoint-cli-v4 account:environment:list
- クライアント ID とクライアントシークレットの環境変数を設定して認証する
    
    $ export ANYPOINT\_CLIENT\_ID=myClientID
    $ export ANYPOINT\_CLIENT\_SECRET=myCLientSecret
    $ export ANYPOINT\_ORG=myOrgId
    $ anypoint-cli-v4 account:environment:list