Automatically generate API Client credentials for an existing Connector
Overview
This step-by-step guide outlines how to update your connect.yaml configuration file to automatically generate API Client credentials.
Requirements
Before you begin, ensure you have the following:
- An existing Connector that uses
connect.yamlfor configuration. - Access to the Composable Commerce API and the necessary credentials.
Update your configuration file
To enable automatic generation of API credentials, update your connect.yaml configuration file.
To prevent configuration conflicts, ensure that the connect.yaml file does not include any variables that will be automatically generated by the API Client generation feature. These autogenerated variables are provided at runtime and should not be manually defined in the configuration.
The following example shows a connect.yaml file with pre-generated Composable Commerce credentials.
With this configuration file, API Client will not be generated automatically.
deployAs:- name: service_app_nameapplicationType: serviceendpoint: /servicescripts:postDeploy: npm run connector:post-deploypreUndeploy: npm run connector:pre-undeployconfiguration:standardConfiguration:- key: CTP_PROJECT_KEYdescription: Project key of the commercetools Composable Commerce Projectrequired: truedefault: 'default-key'securedConfiguration:- key: INTEGRATION_API_KEYdescription: API key for the integrationrequired: true- key: CTP_CLIENT_IDdescription: commercetools Composable Commerce client IDrequired: true- key: CTP_CLIENT_SECRETdescription: commercetools Composable Commerce client secretrequired: true- key: CTP_SCOPEdescription: commercetools Composable Commerce client scope- name: job_app_nameapplicationType: jobendpoint: /jobproperties:schedule: '*/5 * * * *'configuration:standardConfiguration:- key: CTP_PROJECT_KEYdescription: Project key of the commercetools Composable Commerce Projectrequired: truesecuredConfiguration:- key: INTEGRATION_API_KEYdescription: API key for the integrationrequired: true- key: CTP_CLIENT_IDdescription: commercetools Composable Commerce client IDrequired: true- key: CTP_CLIENT_SECRETdescription: commercetools Composable Commerce client secretrequired: true- key: CTP_SCOPEdescription: commercetools Composable Commerce client scope
To enable automatic API Client generation, complete the following steps in your connect.yaml file:
- In the
standardConfigurationobject, remove theCTP_PROJECT_KEYvariable with the Composable Commerce project key: this key will be fetched automatically. - In the
securedConfigurationobject, remove the variables with pre-generated Composable Commerce credentials:CTP_CLIENT_ID,CTP_CLIENT_SECRET, andCTP_SCOPE. - Add an
inheritAsobject and specify the scopes to include for automatically generated API Client credentials as a list ininheritAs.apiClient.scopes, for examplemanage_payments,manage_orders,manage_extenstions(only for service application types that use API Extensions), andmanage_subscriptions(only for event application types that use Subscriptions).
The resulting example connect.yaml looks as follows:
deployAs:- name: service_app_nameapplicationType: serviceendpoint: /servicescripts:postDeploy: npm run connector:post-deploypreUndeploy: npm run connector:pre-undeployconfiguration:securedConfiguration:- key: INTEGRATION_API_KEYdescription: API key for the integrationrequired: true- name: job_app_nameapplicationType: jobendpoint: /jobproperties:schedule: '*/5 * * * *'configuration:securedConfiguration:- key: INTEGRATION_API_KEYdescription: API key for the integrationrequired: trueinheritAs:apiClient:scopes:- manage_payments- manage_orders- manage_subscriptions # only for event application types that use Subscriptions- manage_extensions # only for service application types that use API Extensions
Variables available in the Connect application
With the automatic generation of API Client credentials, the following environment variables will be available for your Connector:
| Field | Description |
|---|---|
CTP_API_URL | Composable Commerce API URL. |
CTP_AUTH_URL | Authentication URL for the Composable Commerce API. |
CTP_CLIENT_ID | API Client ID for the Connector. |
CTP_PROJECT_KEY | Composable Commerce Project key. |
CTP_CLIENT_SECRET | Secret key associated with the Composable Commerce API Client. |
CTP_SCOPE | List of scopes assigned to the API credentials. |