Skip to content

feat(pkce): Default clientId to the client's configured client ID - #423

Merged
gjtorikian merged 1 commit into
mainfrom
pkce-client-id-fallback
Jul 27, 2026
Merged

feat(pkce): Default clientId to the client's configured client ID#423
gjtorikian merged 1 commit into
mainfrom
pkce-client-id-fallback

Conversation

@gjtorikian

Copy link
Copy Markdown
Contributor

Summary

  • Makes $clientId optional across all four PKCEHelper flows — getAuthKitAuthorizationUrl, authKitCodeExchange, getSsoAuthorizationUrl, and ssoCodeExchange — falling back to $this->client->requireClientId() when omitted.
  • Callers no longer have to re-pass a client ID the WorkOS client already carries (constructor argument or WORKOS_CLIENT_ID env var), aligning the PHP SDK with the override-with-fallback pattern used by the other backend SDKs.
  • Explicitly passed client IDs still take precedence over the configured one.
  • An unconfigured client now throws a ConfigurationException with a clear message instead of a TypeError from the missing required parameter.
  • Adds tests covering the fallback, the explicit-argument override, and the ConfigurationException path for both authorization-URL and code-exchange flows.

PKCEHelper's four flows (AuthKit/SSO authorization URL and code
exchange) required callers to re-pass a clientId the WorkOS client
already carries (constructor arg / WORKOS_CLIENT_ID). Make the
parameter optional with a fallback to requireClientId(), aligning PHP
with the other backend SDKs' override-with-fallback pattern. Explicit
arguments still win; an unconfigured client now throws
ConfigurationException instead of a TypeError.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gjtorikian
gjtorikian requested review from a team as code owners July 27, 2026 15:03
@gjtorikian
gjtorikian requested a review from nicknisi July 27, 2026 15:03
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Makes the client ID optional in all four PKCE authorization and code-exchange flows.

  • Falls back to the WorkOS client's configured client ID when no explicit value is supplied.
  • Preserves explicit client-ID overrides and raises ConfigurationException when neither source is configured.
  • Adds tests for configured fallback, explicit override, and missing configuration behavior.

Confidence Score: 5/5

The PR appears safe to merge.

All four changed methods preserve explicit client IDs, resolve omitted values through the existing configuration guard, and pass the resolved value into the correct request field.

Important Files Changed

Filename Overview
lib/PKCEHelper.php Consistently resolves omitted client IDs through requireClientId() before constructing each AuthKit and SSO request.
tests/PKCEHelperTest.php Adds focused coverage for fallback, override, and missing-client-ID behavior without revealing a functional regression.

Reviews (1): Last reviewed commit: "feat(pkce): default clientId to the clie..." | Re-trigger Greptile

@gjtorikian
gjtorikian merged commit f65713b into main Jul 27, 2026
9 checks passed
@gjtorikian
gjtorikian deleted the pkce-client-id-fallback branch July 27, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant