# Replace placeholders and run
# User-Agent is set explicitly so default library agents (e.g. curl) are not rejected by the gateway.
CLIENT_ID="REPLACE-ME" #This is the client ID. No quotes needed.
CLIENT_SECRET="REPLACE-ME" #This is the client secret. No quotes needed.
SCOPE="REPLACE-ME" #This is the scope (looks like url). No quotes needed.
SUB_KEY="REPLACE-ME" #This is the subscription key. No quotes needed.
ORG=REPLACE-ME #This is the organization number. No quotes needed.
TOKEN_RESPONSE=$(curl -sS -m 30 -w "\n%{http_code}" -X POST https://id.talenom.com/api/b2b/oauth2/v1.0/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "User-Agent: Easor-API-Client/1.0" \
-d "grant_type=client_credentials&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&scope=$SCOPE")
TOKEN_HTTP_CODE=$(echo "$TOKEN_RESPONSE" | tail -n1)
TOKEN_BODY=$(echo "$TOKEN_RESPONSE" | sed '$d')
if [ "$TOKEN_HTTP_CODE" != "200" ]; then
echo "Token request failed with HTTP $TOKEN_HTTP_CODE"
echo "$TOKEN_BODY"
exit 1
fi
ACCESS_TOKEN=$(echo "$TOKEN_BODY" | jq -r .access_token)
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
echo "Token response did not contain access_token:"
echo "$TOKEN_BODY"
exit 1
fi
echo "This is your access token: $ACCESS_TOKEN"
curl -v -m 30 "https://apim.talenom.com/organization/v1/organization-info/$ORG" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Ocp-Apim-Subscription-Key: $SUB_KEY" \
-H "User-Agent: Easor-API-Client/1.0"