import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
commercetools: {
type: "app",
app: "commercetools",
}
},
async run({steps, $}) {
return await axios($, {
url: `${this.commercetools.$auth.api_host}${this.commercetools.$auth.projectKey}/stores`,
headers: {
Authorization: `Bearer ${this.commercetools.$auth.oauth_access_token}`,
},
})
},
})
commercetools uses OAuth authentication. When you connect your commercetools account, Pipedream will open a popup window where you can sign into commercetools and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any commercetools API.
Pipedream requests the following authorization scopes when you connect your account:
POST
{{custom_fields.auth_host}}oauth/{{custom_fields.projectKey}}/anonymous/token
content-type: application/x-www-form-urlencoded
accept: application/json
redirect_uri={{oauth.redirect_uri}}
&
grant_type=client_credentials
&
code={{oauth.code}}
&
password={{custom_fields.password}}
&
scope=manage_project:{{custom_fields.projectKey}}
POST
{{custom_fields.auth_host}}oauth/token
content-type: application/x-www-form-urlencoded
accept: application/json
grant_type=refresh_token
&
refresh_token={{oauth.refresh_token}}