Title: [BUG] SSO OIDC: client_secret_basic default causes invalid_client when secret contains special characters · Issue #3626 · simstudioai/sim · GitHub
Open Graph Title: [BUG] SSO OIDC: client_secret_basic default causes invalid_client when secret contains special characters · Issue #3626 · simstudioai/sim
X Title: [BUG] SSO OIDC: client_secret_basic default causes invalid_client when secret contains special characters · Issue #3626 · simstudioai/sim
Description: Bug Description When registering an SSO OIDC provider via register-sso-provider.ts, the tokenEndpointAuthentication field is optional with no default value. When unset, better-auth's SSO plugin (index.mjs:595) defaults to client_secret_b...
Open Graph Description: Bug Description When registering an SSO OIDC provider via register-sso-provider.ts, the tokenEndpointAuthentication field is optional with no default value. When unset, better-auth's SSO plugin (in...
X Description: Bug Description When registering an SSO OIDC provider via register-sso-provider.ts, the tokenEndpointAuthentication field is optional with no default value. When unset, better-auth's SSO plugin...
Opengraph URL: https://github.com/simstudioai/sim/issues/3626
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] SSO OIDC: client_secret_basic default causes invalid_client when secret contains special characters","articleBody":"## Bug Description\n\nWhen registering an SSO OIDC provider via `register-sso-provider.ts`, the `tokenEndpointAuthentication` field is optional with no default value. When unset, better-auth's SSO plugin (`index.mjs:595`) defaults to `client_secret_basic`:\n\n```js\nauthentication: config.tokenEndpointAuthentication === \"client_secret_post\" ? \"post\" : \"basic\"\n```\n\nIn `client_secret_basic` mode, better-auth encodes credentials as `Base64(client_id:client_secret)` **without URL-encoding** the values first, as required by [RFC 6749 §2.3.1](https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1).\n\nThis causes OIDC providers to decode `+` as a space, `=` as a delimiter, etc., resulting in a secret mismatch and `invalid_client` error.\n\n## Steps to Reproduce\n\n1. Register an SSO OIDC provider using `register-sso-provider.ts` without setting `tokenEndpointAuthentication`\n2. Use a client secret that contains `+`, `=`, `/`, or other Base64 special characters\n3. Attempt SSO login\n4. Token exchange fails with `invalid_client`\n\n## Expected Behavior\n\nToken exchange should succeed regardless of special characters in the client secret.\n\n## Root Cause\n\n- `register-sso-provider.ts` passes `tokenEndpointAuthentication` as-is (undefined when not set)\n- `undefined === \"client_secret_post\"` evaluates to `false`, so better-auth uses `\"basic\"`\n- better-auth does not URL-encode credentials before Base64 encoding in `client_secret_basic` mode (violates RFC 6749 §2.3.1)\n\n## Proposed Fix\n\nDefault `tokenEndpointAuthentication` to `'client_secret_post'` in `register-sso-provider.ts` to avoid the upstream encoding issue:\n\n```typescript\ntokenEndpointAuthentication:\n ssoConfig.oidcConfig.tokenEndpointAuthentication || 'client_secret_post',\n```\n\nThis is a workaround — the root cause is in better-auth's SSO plugin, which should URL-encode credentials per RFC 6749 §2.3.1 when using `client_secret_basic`.\n\n## Environment\n\n- Sim version: v0.5.113 (main branch)\n- better-auth: 1.3.12\n- Affected file: `packages/db/scripts/register-sso-provider.ts`","author":{"url":"https://github.com/minijeong-log","@type":"Person","name":"minijeong-log"},"datePublished":"2026-03-17T09:56:18Z","url":"https://github.com/simstudioai/sim/issues/3626"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dc59aa72-4a2a-57ee-1c87-74ccd831fe96 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE1A:34DD79:3C66EB:555E60:6AFB597A |
| html-safe-nonce | 79eb1100178f2b5c83c27be72d287a298b723ba672e8e00f9a137002d761eff9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTFBOjM0REQ3OTozQzY2RUI6NTU1RTYwOjZBRkI1OTdBIiwidmlzaXRvcl9pZCI6IjI5NDkzNzY5NzA0OTM0ODMzODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c148042656adc4425c2b28cf5e7735041640293a607df64d475e33e8a1a17ec8 |
| hovercard-subject-tag | issue:4087430620 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/simstudioai/sim/3626/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e1fa0fb515227e8154de81f21e3d908737c6b377b473365f6aa45cc2519ec5d7/simstudioai/sim/issues/3626 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e1fa0fb515227e8154de81f21e3d908737c6b377b473365f6aa45cc2519ec5d7/simstudioai/sim/issues/3626 |
| og:image:alt | Bug Description When registering an SSO OIDC provider via register-sso-provider.ts, the tokenEndpointAuthentication field is optional with no default value. When unset, better-auth's SSO plugin (in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | minijeong-log |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width