Log in to an instance with the Sitecore CLI
For advanced use of the Sitecore Command Line Interface (CLI) against a SitecoreAI instance, such as using specific authorities and audiences, you can use the sitecore cloud login command.
For regular operations against a SitecoreAI instance, you can use the commands provided by the Sitecore CLI XM Cloud plugin.
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
For logging in to an instance using sitecore cloud login, the CLI allows two flows of authentication and authorization:
-
An interactive user login, using a device code flow.
-
A non-interactive client login, using a client credentials flow. This is used by clients such as Continuous Integration servers.
Run the dotnet sitecore cloud login --help command for details on the cloud login command.
Use an interactive user login (device code flow)
To log in with an interactive user login to an SitecoreAI instance, you must use the following:
-
The authority URL. The default authority URL is
https://auth.sitecorecloud.io. -
The audience URL:
https://api.sitecorecloud.io. -
The predefined client ID:
Chi8EwfFnEejksk3Sed9hlalGiM9B2v7. -
The URL of the SitecoreAI instance.
-
Your username.
-
Your password.
To log in:
-
In the console, go to your project folder.
-
Log in with the following command:
RequestResponsedotnet sitecore cloud login --authority https://<AUTHORITY_URL> --cm https://<SITECOREAI_INSTANCE> --audience https://<SITECOREAI_AUDIENCE_URL> --client-id <CLIENT_ID> --allow-write trueXM Cloud is now SitecoreAISome code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
The
sitecore cloud logincommand opens a login page in your browser. -
On the login page, enter your username and password and click OK.
The
sitecore cloud logincommand stores your login arguments in the.sitecore/user.jsonfile together with an access token. You are now logged in, and you can close the login webpage.ImportantDo not commit the
.sitecore/user.jsonfile to source control because it contains privileged information.
After logging in with the device flow, if you want to switch to the client credentials (non-interactive) flow, run the following command:
dotnet sitecore cloud login --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET> --client-credentials trueWhen switching to the non-interactive login flow, use the credentials generated when creating an authentication/automation client for your environment or organization.
Use a non-interactive client login (client credentials flow)
To use a non-interactive login flow with a SitecoreAI instance, you need the following:
-
An authentication/automation client for your organization or environment. This provides a client ID and a client secret.
-
The authority URL. The default authority URL is
https://auth.sitecorecloud.io. -
The audience URL
https://api.sitecorecloud.io. -
The URL of the SitecoreAI instance.
To log in:
-
In the console, go to your project folder.
-
Log in with the following command:
RequestResponsedotnet sitecore cloud login --authority https://<AUTHORITY_URL> --cm http://<SITECOREAI_INSTANCE> --audience https://<SITECOREAI_AUDIENCE_URL> --allow-write true --client-credentials true --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET>
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
After logging in with the client credentials flow, if you want to switch to the device flow, run the following command:
dotnet sitecore cloud login --client-credentials false --client-id <CLIENT_ID>When switching to the interactive login flow, use the predefined client ID Chi8EwfFnEejksk3Sed9hlalGiM9B2v7.