# Commercetools (prebuilt connector)

## Description

**Commercetools** provides all composable components needed to build and run shopping experiences.

## API documentation

API documentation for Commercetools (used to build this connector) can be found via the link below:

{% embed url="<https://docs.commercetools.com/api/>" %}

## Authentication&#x20;

When adding connector instances for Commercetools, the following authentication methods are supported:

* [OAuth 2 (client credentials)](#oauth-2-authorisation-code)

### OAuth 2 (client credentials)

{% tabs %}
{% tab title="Credentials" %}
When a user chooses to [add a connector instance](https://doc.wearepatchworks.com/product-documentation/connectors-and-instances/working-with-instances/adding-an-instance) using **OAuth 2 (client credentials)** authentication, the credentials below are prompted:

<table><thead><tr><th>Credential</th><th data-type="checkbox">Required?</th><th>Notes</th></tr></thead><tbody><tr><td><code>Scope</code></td><td>true</td><td>The <strong>scopes</strong> selected when your API client was created for Patchworks (via the Commercetools dashboard). Multiple scopes should be separated by spaces.</td></tr><tr><td><code>Client ID</code></td><td>true</td><td>The <strong>clientid</strong> generated when your API client was created for Patchworks (via the Commercetools dashboard).</td></tr><tr><td><code>Secret</code></td><td>true</td><td>The <strong>secret</strong> generated when your API client was created for Patchworks (via the Commercetools dashboard).</td></tr><tr><td><code>Project key</code></td><td>true</td><td>The unique project key for your Commercetools environment. </td></tr><tr><td><code>Commercetools server region</code></td><td>true</td><td>The server region to be used for token requests. The default is <code>europe-west1.gcp</code>.</td></tr><tr><td><code>Grant type</code></td><td>true</td><td>Set to <code>client_credentials</code>.</td></tr><tr><td><code>Response authentication token key</code></td><td>true</td><td>Set to <code>access_token.</code></td></tr><tr><td><code>Client type</code></td><td>true</td><td>Set to <code>confidential.</code></td></tr></tbody></table>
{% endtab %}

{% tab title="Obtaining credentials" %}

#### Project key

Your unique project key forms part of the URL that you use to access Commercetools - for example:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FCUpm5Ue0W2YUsubbKkMC%2Fct1.png?alt=media\&token=1e42779d-a9f3-4be8-96b2-300d7e3d2ecb)

In this example, our `project key` is `product-patchworks`.

#### Server region

Your server region forms part of the URL that you use to access Commercetools - for example:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FCUpm5Ue0W2YUsubbKkMC%2Fct1.png?alt=media\&token=1e42779d-a9f3-4be8-96b2-300d7e3d2ecb)

In this example, our `server region` is `europe-west1.gcp`.

#### Client id, Client secret, Scope

These details are generated when you add an API client to your Commercetools implementation, for Patchworks. These details are only displayed once therefore, they should always be added to a password manager for later use.

If you don't have an existing API client for Patchworks, you can create one. To do this, follow the steps below.

**Step 1**\
Log into Commercetools

**Step 2**\
Select **settings** from the left-hand navigation bar:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FiVm8L9rCrYLOs2VhbdrG%2Fct2.png?alt=media\&token=035f4b81-3f1a-410a-a547-66b84d35a2fc)

**Step 3**\
Select **developer settings**:

<img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FWoywFvYOfj4TuhzSrf8V%2Fct2a.png?alt=media&#x26;token=cfe3d74c-0d4c-4616-a4f3-e5987fe8634b" alt="" data-size="original">

**Step 4**\
Click the **create new API client** button:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FCMG6uTl7idWDRbCgMO4L%2Fct3.png?alt=media\&token=33768d87-f546-4147-938a-c37133c17a12)

**Step 5**\
Enter a name for this client and then select the required access scopes:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FCWSXi9HMjdB19IN1jcC2%2Fct4.png?alt=media\&token=3b9132cf-66c8-4e9d-8a9b-ca917010db3f)

**Step 6**\
Create the API client.&#x20;
{% endtab %}
{% endtabs %}
