Skip to content

forcedotcom/sf-skills / skills/platform-models-api-configure

platform-models-api-configure

Verified

Configure (or troubleshoot) an AI coding agent or CLI to route through the Salesforce Models API using a signed OrgJWT. Use this skill when pointing an agent at the Salesforce model endpoint (api.salesforce.com/ai/gpt/v1), setting up OrgJWT / Bedrock-mode auth, wiring the agent's settings, API-key helper, and credentials file for the Salesforce endpoint, or fixing Models API 401 / 404 / "model not available" errors. DO NOT TRIGGER when the user needs to create or configure the Salesforce Connected App itself (use integration-connectivity-connected-app-configure) or set up Named Credentials / callout auth (use integration-connectivity-generate).

FileKindSize
SKILL.mdskill md8.2 KB
scripts/get-orgjwt.shexecutablescript2.2 KB

scripts/get-orgjwt.sh

View on GitHub
#!/usr/bin/env bash
# Mint a signed OrgJWT (sfap_api scope) via the OAuth 2.0 client_credentials
# flow and print it to stdout. This is the value Claude Code sends as
# `Authorization: Bearer <jwt>` to the Salesforce Models API.
#
# Credentials come from an env file passed as $1 (recommended — that's what the
# generated settings.json does), or from the environment:
#   SF_INSTANCE_URL   e.g. https://my-org.my.salesforce.com
#   SF_CLIENT_ID      connected-app consumer key   (app needs the sfap_api scope
#   SF_CLIENT_SECRET  connected-app consumer secret  + client_credentials enabled)
#
# Usage (as apiKeyHelper):  bash get-orgjwt.sh /path/to/.orgjwt.env
set -euo pipefail

command -v jq >/dev/null 2>&1 || { echo "get-orgjwt: jq is required but not found on PATH" >&2; exit 1; }

CREDS="${1:-${SFGW_CREDS:-}}"
if [ -n "$CREDS" ]; then
  [ -f "$CREDS" ] || { echo "get-orgjwt: creds file not found: $CREDS" >&2; exit 1; }
  # Read only the three expected KEY=VALUE assignments. We deliberately do NOT
  # `source` the file — sourcing would execute any shell code a malformed or
  # tampered creds file happened to contain (e.g. command substitution).
  while IFS='=' read -r key val; do
    case "$key" in
      SF_INSTANCE_URL|SF_CLIENT_ID|SF_CLIENT_SECRET)
        val="${val%\"}"; val="${val#\"}"   # strip surrounding double quotes
        export "$key=$val" ;;
    esac
  done < "$CREDS"
fi
: "${SF_INSTANCE_URL:?set SF_INSTANCE_URL (in creds file or env)}"
: "${SF_CLIENT_ID:?set SF_CLIENT_ID}"
: "${SF_CLIENT_SECRET:?set SF_CLIENT_SECRET}"

RESPONSE=$(curl -s --location "${SF_INSTANCE_URL%/}/services/oauth2/token" \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode "client_id=${SF_CLIENT_ID}" \
  --data-urlencode "client_secret=${SF_CLIENT_SECRET}" \
  --data-urlencode 'grant_type=client_credentials')

TOKEN=$(printf '%s' "$RESPONSE" | jq -r '.access_token // empty')
if [ -z "$TOKEN" ]; then
  ERR=$(printf '%s' "$RESPONSE" | jq -r '.error_description // .error // empty' 2>/dev/null)
  [ -n "$ERR" ] || ERR="check connected-app creds / sfap_api scope / client_credentials flow"
  echo "get-orgjwt: token request failed — $ERR" >&2
  exit 1
fi
printf '%s' "$TOKEN"
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall