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

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

> !注Sitecore Experience Manager(XM)クラウドインスタンスに対して認証するには、[XM Cloudプラグインが提供するcloud loginコマンド](https://doc.sitecore.com/sai/ja/developers/sitecoreai/sitecore-command-line-interface/sitecore-cli-command-reference/the-cli-cloud-command/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://<sitecore identity server> --cm https://<sitecore instance> --allow-write true

出力:

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://<sitecore identity server> --cm https://<sitecore instance> --allow-write true --client-credentials true --client-id <client id> --client-secret <client secret>

-   httpsプロトコルの制限を回避する:

dotnet sitecore login --cm https://<sitecore instance> --auth http://<sitecore identity server> --allow-write true --client-id <client id> --client-secret <client secret> --client-credentials true --insecure

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