Skip to content

OIDC token endpoint rejects public clients with invalid_client (regression from #452) #513

Closed

Description

@melvincarvalho

Summary

xlogin (and any Solid app using dynamic client registration with token_endpoint_auth_method: "none") can complete the authorization code flow against JSS but cannot exchange the code for tokens — the token endpoint returns 401 invalid_client. This is blocking login across the solid-apps suite (explorer, plaza, timeline, hub-mashlib all hit it).

Reproduced against JSS at HEAD (commit fdc219f, package.json says 0.0.201).

Repro

jss start \
  --port 5446 \
  --host localhost \
  --root /tmp/jss-test/pod-data \
  --single-user \
  --single-user-password test \
  --idp \
  --notifications \
  --mashlib-module <any solid app entry>

Visit http://localhost:5446/public/ in a browser, click any Solid app's Login button (e.g. xlogin's), enter username/password.

  1. POST /idp/interaction/<id>/login → 302 (login succeeds)
  2. Browser redirected back to the app with ?code=...
  3. xlogin posts to /idp/token with the code → 401 invalid_client

Log excerpt

err: invalid_client
stack: InvalidClientAuth: invalid_client
    at authenticateClient (oidc-provider/lib/shared/client_auth.js:166:17)
    at async setWWWAuthenticateHeader (oidc-provider/lib/shared/client_auth.js:49:11)
    at async selectiveBody (oidc-provider/lib/shared/selective_body.js:49:5)
error_description: "client authentication failed"
msg: "oidc-provider grant error"

POST /idp/token statusCode=401 contentLength=77 responseTime=1.74ms

Body length 77 bytes is consistent with the standard public-client payload (grant_type=authorization_code&code=...&redirect_uri=...&client_id=...&code_verifier=...) — no client_secret, which is correct for a none-auth client.

Why this matters

This isn't an xlogin-specific problem. It's the OIDC token endpoint refusing every public client. Public clients are the canonical Solid flow: browser-based apps that dynamically register and authenticate per-session via PKCE alone. If JSS's token endpoint can't honour that, no in-browser Solid app can log in — including:

  • solid-apps/explorer (logging in to read private containers)
  • solid-apps/plaza (logging in to post)
  • solid-apps/timeline (logging in to post)
  • solid-apps/hub (via the new hub-mashlib.js data-browser bundle, just spiked)
  • Any third-party Solid client using @inrupt/solid-client-authn-browser or similar

Suspected origin

PR #452 (merged 2026-05-14, included in JSS 0.0.194+) reworked stale-session-cookie + consent-crash recovery. It touched src/idp/provider.js and src/idp/interactions.js. The token endpoint went from working (≤ 0.0.193) to silently rejecting public clients sometime after that merge.

Relevant code paths:

  • src/idp/provider.js:341 — token_endpoint_auth_method: 'none' is in clientDefaults, so dynamically-registered clients SHOULD inherit none. They're being rejected anyway, so either the default isn't taking effect or oidc-provider's client-auth check is over-strict for the none path.
  • src/idp/provider.js:379 — there's a CORS branch on client.tokenEndpointAuthMethod === 'none' that exists, suggesting we knew about this case at some point.

Suggested investigation

  1. Inspect the dynamically-registered client record in the IdP adapter — confirm token_endpoint_auth_method is being persisted as none after POST /idp/reg.
  2. Trace authenticateClient in oidc-provider's client_auth.js:166 — what client metadata is it seeing for these requests? Is it expecting client_secret_basic or client_secret_post when it should accept the none path?
  3. Diff provider.js against pre-OIDC server_error after account delete + re-create (stale session) #452 — anything in the client-auth or grant-type pipeline that would affect public-client acceptance?
  4. Consider whether expireSessionCookiesKoa or the stale-session redirect is corrupting state in a way that makes the subsequent /idp/token request appear to be on a different client.

Workaround

Pin JSS to 0.0.193 in package.json (and npm install) to restore login. This is what jspod / nosdav-server consumers may need to do until the fix lands.

Related

  • The solid-apps suite of in-browser Solid clients all share this dependency. Fixing the token endpoint unblocks all of them at once.
  • Earlier conversation in the issue tracker about the same observation (search: invalid_client, regression).

Activity

  1. melvincarvalho commented on May 20, 2026

    @melvincarvalho
    ContributorAuthor

    Updated diagnosis — not a JSS regression

    After follow-up investigation, the root cause is stale xlogin client cache, not a JSS code bug. Closing recommendation: keep open as a tracker for the JSS-side UX improvement (better error message + recovery affordance) but the user-visible "login broken" symptom is fixable by clearing localStorage.

    Evidence

    Curl-only test passes: registering a fresh public client + posting to /idp/token with a junk code returns invalid_grant (expected), not invalid_client. Means JSS's token endpoint accepts public clients fine when the registration is current.

    Code review of PR #452: the 5 commits only touch cookie expiry on account-delete + renderError stale-session recovery. None modify the client adapter or authenticateClient lookup. The 373da9c "gate on GET only" commit ensures POST /idp/token never enters the cookie-expiry branch.

    The actual failure path: oidc-provider's authenticateClient calls await Client.find(client_id). If unknown → InvalidClientAuth. xlogin caches client_id in localStorage per IdP origin. When JSS restarts with a fresh data dir, the previously-registered client no longer exists in the adapter — but xlogin still tries to use the cached client_id. Result: 401 invalid_client.

    Workaround for end users

    Clear localStorage + cookies for the pod IdP origin. xlogin will re-register on the next login attempt.

    Fix surface

    Two complementary improvements possible:

    1. xlogin side (primary): catch invalid_client on /idp/token, drop the cached client_id, re-register, retry. One round trip recovery, transparent to the user.
    2. JSS side (secondary): include a more specific error hint in the response body when Client.find returns undefined, distinguishing "client not registered" from "client auth method mismatch". Helps any client library do the same recovery.

    I'll file (1) on the xlogin repo. (2) can live here if folks want — happy to close otherwise.

    Apology for the noise

    The original report blamed PR #452 based on circumstantial timing. The bisect / code-review investigation has cleared #452 — that PR fixes a real bug (account-delete + re-create) and doesn't regress this path. Sorry for the misdirection.

  2. melvincarvalho commented on May 20, 2026

    @melvincarvalho
    ContributorAuthor

    Resolved — not a JSS bug

    After thorough investigation across multiple JSS versions (0.0.193 through HEAD/0.0.202), this was operator error on my end, not a regression in JSS:

    The repro instance was started with --single-user-password test, which created the single-user account with that password. I then tried logging in as me / me (matching jspod's convention). Authentication failed silently, the IdP re-rendered the login form, and I misread the symptom as invalid_client at /idp/token based on stale browser state from earlier debugging.

    After provisioning the account fresh with the matching password (--single-user-password me, wipe .idp/accounts/), login completes cleanly and the full OIDC flow succeeds end-to-end against current HEAD.

    Real bug from this investigation, worth filing separately: when interaction.lastError is set after a failed login, the IdP's login page re-renders identically without surfacing the error to the user. The lastError is plumbed into loginPage(uid, params.client_id, interaction.lastError) in src/idp/interactions.js:30 but apparently never rendered visibly. That's the real UX bug that wasted hours of investigation here. I'll file that one separately.

    PR #452 cleared — it does what it says (recovers from stale session cookies after account delete + re-create) and does not regress public-client login.

    Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions