Set up publisher-managed OAuth
Set up publisher-managed OAuth
If your connector authenticates to the external service with OAuth, Zendesk can provision and manage one OAuth client on behalf of all customers - you supply the credentials encrypted, and no customer ever handles your client secret. This page covers registering that OAuth app, encrypting its secret, and creating settings.json. You declare the matching authentication in the connector source - see Defining authentication and actions.
Terminology
- Publisher-managed OAuth client: one OAuth application that you (the publisher) register with the third-party service; all Zendesk customers share it. You supply it to Zendesk encrypted, through
settings.json. (Marketplace documentation also refers to this as a "global OAuth" client.) - Customer authorization: with the
authorization_codegrant, each customer signs in to the third-party service and authorizes their own connection against your publisher-managed client. - Publisher-managed connection: with the
client_credentialsgrant there is no customer sign-in, so Zendesk provisions the connection itself from your publisher-managed client. - Account-level OAuth: each customer supplies their own OAuth client credentials during the standard connection setup. That model is covered by the SDK documentation and needs no
settings.json; it is not part of this guide.
For public connectors, the supported models are (both OAuth rows are publisher-managed, that is, one global client for all customers):
| Authentication | Who provides the credentials |
|---|---|
bearer_token, api_key, basic_authentication | Each Zendesk customer enters their own credentials in the standard connection setup experience. Skip to Package the connector bundle - these connectors need no settings.json. |
oauth2, authorization_code grant | Register a global OAuth client for the connector, supplied through settings.json. Each customer then authorizes a connection interactively. |
oauth2, client_credentials grant | Register a global OAuth client for the connector, supplied through settings.json. Zendesk provisions a publisher-managed connection with it. |
Registering your OAuth app with the provider
Register one OAuth application with the external provider - for the GitHub example used in this guide, at github.com/settings/developers. Note its client id, client secret, authorization URL, token URL, and scopes; you need them for settings.json.
For the authorization_code grant, set the provider's authorization callback URL (GitHub calls it "Authorization callback URL") to the Zendesk callback URL:
https://zis.zendesk.com/api/services/zis/connections/oauth/callback
Downloading the public encryption key
Your client secret is encrypted locally against the Zendesk public key. Zendesk never receives the plaintext secret, and the secret never appears in connector source code.
The encryption-key endpoint and the Zendesk Command Line Interface (ZCLI) command will be available in an upcoming release. Either option downloads the active Zendesk RSA public key - download it again before each submission so the bundle uses the active key.
Option A - ZCLI (recommended). The command uses your authenticated ZCLI profile, validates the key, and writes it to the requested file without printing it to the terminal:
zcli connectors:encryption-key --output public-key.pem
Option B - curl with a Zendesk API token. Call the same endpoint on your Zendesk account as an administrator and extract the PEM with jq:
curl -s --fail \-u "[email protected]/token:$ZENDESK_API_TOKEN" \https://YOUR_SUBDOMAIN.zendesk.com/flowstate/connectors/public/encryption-key \| jq -r '.public_key' > public-key.pem
Keep the API token in an environment variable or credential store - never in a committed script or a shared log. Whichever option you use, confirm the downloaded file is a valid RSA public key:
openssl pkey -pubin -in public-key.pem -text -noout | head -1# Public-Key: (<key size> bit)
Encrypting the client secret
Zendesk does not require a particular scripting language, but the output must be a compact JWE using RSA-OAEP-256 key encryption, A256GCM content encryption, a protected kid header equal to the base64url SHA-256 fingerprint of the public key's SPKI bytes, and a JSON payload of {"field":"authentication.client_secret","value":"<secret>"}. The enc:v1: envelope prefix is not part of the script output - you add it in settings.json.
The following Node.js example uses the standard jose package. Install it as a development dependency and pin the version in your lockfile:
npm install --save-dev jose
Create tools/encrypt-client-secret.mjs:
import { readFile } from 'node:fs/promises'import { createHash, createPublicKey } from 'node:crypto'import { CompactEncrypt, importSPKI } from 'jose'const publicKeyPath = process.argv[2]if (!publicKeyPath) {console.error('Usage: node tools/encrypt-client-secret.mjs <public-key.pem>')process.exit(1)}const publicKeyPem = await readFile(publicKeyPath, 'utf8')const parsedKey = createPublicKey(publicKeyPem)if (parsedKey.type !== 'public' || parsedKey.asymmetricKeyType !== 'rsa') {throw new Error('The encryption key must be an RSA public key')}const spki = parsedKey.export({ type: 'spki', format: 'der' })const kid = createHash('sha256').update(spki).digest('base64url')const encryptionKey = await importSPKI(publicKeyPem, 'RSA-OAEP-256')const chunks = []let byteLength = 0for await (const chunk of process.stdin) {byteLength += chunk.length// The platform limit is 4 KB on the whole decrypted JSON payload// ({"field":...,"value":...}); reject oversized input early.if (byteLength > 4000) {throw new Error('The client secret exceeds the maximum supported size')}chunks.push(chunk)}const input = Buffer.concat(chunks)let end = input.lengthif (end >= 2 && input[end - 2] === 0x0d && input[end - 1] === 0x0a) {end -= 2} else if (end >= 1 && input[end - 1] === 0x0a) {end -= 1}if (end === 0) {input.fill(0)throw new Error('The client secret cannot be empty')}try {const secret = input.subarray(0, end).toString('utf8')const payload = new TextEncoder().encode(JSON.stringify({field: 'authentication.client_secret',value: secret}))const compactJwe = await new CompactEncrypt(payload).setProtectedHeader({alg: 'RSA-OAEP-256',enc: 'A256GCM',kid}).encrypt(encryptionKey)process.stdout.write(`${compactJwe}\n`)} finally {input.fill(0)}
Do not pass the client secret as a command-line argument - arguments are visible in shell history and process listings. Pipe it on stdin from your approved secret manager. The first command in the pipe is a placeholder: use whatever command fetches the secret and prints only the secret to stdout - for example op read "op://Vault/GitHub OAuth App/client_secret" (1Password CLI), vault kv get -field=client_secret secret/github-oauth-app (HashiCorp Vault), or aws secretsmanager get-secret-value --secret-id github-oauth-app --query SecretString --output text (AWS Secrets Manager):
your-secret-manager-command | # prints only the secret, e.g. op read "op://Vault/GitHub OAuth App/client_secret"node tools/encrypt-client-secret.mjs public-key.pem \> encrypted-client-secret.txt
For a temporary shell variable - for example, your GitHub OAuth app's client secret - disable command tracing and keep the variable out of the child process environment:
set +xprintf '%s' "$GITHUB_OAUTH_CLIENT_SECRET" |env -u GITHUB_OAUTH_CLIENT_SECRET \node tools/encrypt-client-secret.mjs public-key.pem \> encrypted-client-secret.txtunset GITHUB_OAUTH_CLIENT_SECRET
The script writes a single line - the encrypted secret as compact JWE. When you copy it into settings.json, prefix it with enc:v1: (the platform accepts only that envelope format). Although encrypted, treat the value as sensitive provisioning material - do not publish it in logs, tickets, or source control.
Creating settings.json
Create one settings.json file. Projects scaffolded with zcli connectors:create include a skeleton at src/settings.json - fill in the OAuth client details you registered earlier: client_id, auth_url, token_url, default_scopes, and the encrypted client_secret. When the file is at that location, zcli connectors:bundle copies it into the bundle automatically and includes it in the generated ZIP archive. You can also keep the file anywhere outside the project and copy it into dist/ after bundling. See Package the connector bundle.
The completed file contains sensitive provisioning material, so keep it out of source control. If you keep it inside the project at src/settings.json, add the file to .gitignore. Replace the example encrypted value with enc:v1: followed by the complete output from the encryption script.
Authorization code - the GitHub connector example:
{"authentication": {"type": "oauth2","grant_type": "authorization_code","client_id": "your-github-oauth-app-client-id","client_secret": {"encrypted_value": "enc:v1:<compact-jwe>"},"auth_url": "https://github.com/login/oauth/authorize","token_url": "https://github.com/login/oauth/access_token","default_scopes": "repo read:user"}}
Client credentials - for providers that support this grant (GitHub OAuth apps don't; use the authorization code flow for GitHub):
{"authentication": {"type": "oauth2","grant_type": "client_credentials","client_id": "your-publisher-client-id","client_secret": {"encrypted_value": "enc:v1:<compact-jwe>"},"token_url": "https://auth.example.com/oauth/token","default_scopes": "records.read records.write"}}
Per-customer subdomain providers - if the OAuth provider hosts each customer at their own subdomain, use the {{oauth_url_subdomain}} placeholder in the URL hostnames. It resolves from the connector's config.oauth_url_subdomain (see Defining authentication and actions):
{"authentication": {"type": "oauth2","grant_type": "authorization_code","client_id": "your-publisher-client-id","client_secret": {"encrypted_value": "enc:v1:<compact-jwe>"},"auth_url": "https://{{oauth_url_subdomain}}.example.com/oauth/authorize","token_url": "https://{{oauth_url_subdomain}}.example.com/oauth/token","default_scopes": "records.read records.write"}}
Rules:
- The file contains one root property,
authentication. Unknown properties are rejected - do not add metadata. typeandgrant_typemust exactly match the connector declaration.client_secretmust containencrypted_value; plaintext is rejected.- OAuth URLs must use HTTPS and a publicly routable host. Do not use localhost, private IP addresses, URL user information, fragments, or arbitrary
{{inputs.*}}templates. The only supported URL placeholder is{{oauth_url_subdomain}}in the hostname, where the connector contract permits it. - For
authorization_codeconnectors, the OAuth application must be registered with the Zendesk callback URL:https://zis.zendesk.com/api/services/zis/connections/oauth/callback