---
title: "Log in with the Content Hub CLI"
slug: "log-in-with-the-content-hub-cli"
abstract: "How to obtain client credentials and log in to Content Hub."
---
# Log in with the Content Hub CLI

To log in to your Sitecore Content Hub instance, run the following command:

```shell
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:

- `name` is a unique identifier that lets you manage multiple connections to different instances (for example, staging and production or different projects and customers).
- `url` is the base URL to your instance.
- `client-id` is the OAuth client ID that you want to use for the authentication flow.
- `client-secret` is the client secret for the specified OAuth client.

> [!note]
> 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:

```shell
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/>

```

> [!important]
> 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:

```text
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>

```