Skip to content

Instantly share code, notes, and snippets.

@pbrumblay
Last active June 16, 2022 15:09
Show Gist options
  • Save pbrumblay/71e097d53e71fddca798377005322071 to your computer and use it in GitHub Desktop.
Save pbrumblay/71e097d53e71fddca798377005322071 to your computer and use it in GitHub Desktop.
Curl script to exercise CT API
#!/bin/sh
# Requests manage_project which is full control over project.
# Need to define:
# CT_PROJECT_KEY
# CT_CLIENT_ID
# CT_SECRET
#
# Example queries a product by id.
ctapiurl="https://api.us-central1.gcp.commercetools.com/$CT_PROJECT_KEY"
token=`curl https://$CT_CLIENT_ID:[email protected]/oauth/token -X POST -d "grant_type=client_credentials&scope=manage_project:$CT_PROJECT_KEY" | sed 's/{"access_token":"\([^"]*\).*/\1/'`
curl -H "Authorization: Bearer $token" $ctapiurl/products/bf1955bf-6342-4d50-b2fc-f9c88fb49504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment