---
title: "CLIのログインコマンド"
slug: "the-cli-login-command"
abstract: "DevEx CLIのログインコマンドを記述し、Sitecoreインスタンスで追加のCLIコマンドを含むプラグインを許可します。"
---
# CLIのログインコマンド

[Sitecore CLI](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/sitecore-command-line-interface.html "Sitecore Command Line Interface")には、開発者がSitecoreインスタンスにログインできるloginコマンドが含まれています。

> !注Sitecore Experience Manager(XM)クラウドインスタンスに対して認証するには、[XM Cloudプラグインが提供するcloud loginコマンド](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/the-cloud-login-command.html "The cloud login command")を使用します。

## 使用例

Sitecore CLI loginコマンドはSitecore CLI内で以下の方法で起動されます。

dotnet sitecore login options

## オプション

loginコマンドで以下のオプションを利用できます:

オプション

必須

概要

\--authority, --auth

いいえ

環境の識別権限(アイデンティティサーバーやAADテナントURLなど)。

\--audience

いいえ

トークンを発行したオーディエンスの一意識別子。

\--environment, -n

いいえ

使用Sitecore環境の名前付き。デフォルト: 'default'。

\--cm

いいえ

接続先はSitecoreコンテンツ管理ホスト名です。

\--allow-write

いいえ

環境へのデータ書き込みを有効にしてください。

\--client-credentials

いいえ

クライアントの認証情報(CI/CDや共有シークレット用)を使いましょう。

\--client-id

いいえ

送信するOAuth ClientIDです。デバイス認証はデフォルトで 'Device' 、クライアント認証は 'SitecoreCLIServer' です。

\--client-secret

いいえ

送信するOAuthクライアントの秘密。クライアント認証のみに使用されます。

\--config, -c

いいえ

ルート sitecore.json ディレクトリへのパス。デフォルト:現在の作業ディレクトリ。

\--help, -h, -?

いいえ

開発者のヘルプやコマンドの使用情報を表示します。

\--trace, -t

いいえ

コマンドに関する追加の診断や詳細な情報を出力します。

\--insecure, -k

いいえ

安全でない(http)権限URLの使用を可能にします。クライアント認証フロー(\--client-credentials true)でのみ適用可能です。バージョン4.1.0以降で利用可能。

\--ref, -r

いいえ

既存の環境にログインし、その認証情報を使います。 \--cm と \--allow-write パラメータの提供が必要です。  
  
例えば: dotnet sitecore login --ref <your environment> --cm https://<sitecore instance> --allow-write true。

## 例

以下は、インタラクティブなユーザーログインにloginコマンドを使う例です:

-   コマンド:結果
-   dotnet sitecore login --authority https:// --cm https:// --allow-write truedotnet sitecore login: Output:

Logging in to Sitecore. You should see a browser window open shortly.
DeviceLogin User Code : 1234
DeviceLogin Authentication url : https://<sitecore identity server>/device?userCode=1234
DeviceLogin Authorization pending. Waiting.
DeviceLogin Authorization pending. Waiting.
Your login is complete. You can close the browser tab now.
Login information has been saved.

以下は非対話的なユーザーログイン時にloginコマンドを使用する例です:

-   コマンド:説明
-   dotnet sitecore login --authority https:// --cm https:// --allow-write true --client-credentials true --client-id \--client-secret : 非 [インタラクティブなクライアントログイン](https://doc.sitecore.com/xp/en/developers/104/developer-tools/configure-a-non-interactive-client-login.html)を使用。
-   dotnet sitecore login --cm https:// --auth http:// --allow-write true --client-id \--client-secret \--client-credentials true --insecure: https プロトコル制限を回避してください。

詳細については、[CLIを使ってSitecoreインスタンスにログイン](https://doc.sitecore.com/xp/ja/developers/103/developer-tools/log-in-to-an-instance-with-the-sitecore-cli.md "Log in to an instance with the Sitecore CLI")する方法を参照してください。