Log in with the Content Hub CLI
To log in to your Sitecore Content Hub instance, run the following command:
ch-cli endpoint add --name <NAME> --url <YOUR_CONTENT_HUB_URL>/ --client-id <OAUTH_CLIENT_ID> --client-secret <OAUTH_CLIENT_SECRET>This command includes the following parameters:
-
nameis a unique identifier that lets you manage multiple connections to different instances (for example, staging and production or different projects and customers). -
urlis the base URL to your instance. -
client-idis the OAuth client ID that you want to use for the authentication flow. -
client-secretis the client secret for the specified OAuth client.
If you have the necessary permissions, you can see these values in Content Hub. Go to Manage > OAuth clients and, in the list, click CLI.
The login command redirects you to the specified Content Hub instance, where you can grant permissions to the client. The default redirect URI is http://localhost:9000/, but you can override this by adding the --redirect-uri parameter to your command as shown in the following example:
ch-cli endpoint add --name <NAME> --url https:/ <YOUR_CONTENT_HUB_URL>/ --client-id <OAUTH_CLIENT_ID> --client-secret <OAUTH_CLIENT_SECRET> --redirect-uri <HTTP://LOCALHOST:9123/>
The value of --redirect-uri must match the redirect URL of your OAuth client exactly.
To streamline the login process, you can include your username and password in the add command. This allows you to automatically log in without needing to manually grant permissions:
ch-cli endpoint add --name <NAME> --url <YOUR_CONTENT_HUB_URL>/ --client-id <OAUTH_CLIENT_ID> --client-secret <OAUTH_CLIENT_SECRET> --username <USER_NAME> --password <PASSWORD>