8000 No first-party app has requested follow consent, so every follow call 403s with no_grant · Issue #828 · OxyHQ/oxy · GitHub
[go: up one dir, main page]

Skip to content

No first-party app has requested follow consent, so every follow call 403s with no_grant #828

Open

Description

@NateIsern

Status 2026-09-30 (audited against main f345d27)
Blocker still there: followCapability.service.ts:137-139 returns no_grant without an app_grants row, no app spec in seedOxyApplicationsSpecs.ts requests follow scopes, and the SDK has no path to ask for them. Second gap: device-flow finalize (authSession.service.ts:787) skips the grant for trusted apps even when a scope needs consent (OAuth /authorize, auth.ts:2572, doesn't). The first half of this body is retracted in the comments; sign-in has since been rewritten (#1412, #1422) — re-check whether those sessions get an auth_sessions row.


#809's authorization model is built on the OAuth authorization record. First-party Oxy apps do not create one, so every follow call from Mention, Syra or Mercaria will 403 for real users.

Verified against the code, not inferred:

  • auth_sessions rows are created by exactly one route — POST /auth/session/create — and linked to a session by exactly one other, POST /auth/session/authorize/:sessionToken. Both are the QR / Commons-approval / OAuth authorize flow. (grep 'insert(authSessions)' returns a single non-test hit.)
  • The device-first path mints a session from {deviceId, deviceSecret, accountId} and writes a sessions row that has no application column at all — every column listed, there is none.
  • resolveFollowCapability joins auth_sessions.authorized_session_id → sessions.session_id. For a device-first session no such row exists, so it returns no_application, and every route on /v2/follows and /v2/follow-targets refuses.

The three shipped integrations are correct code against an unreachable API. Each was verified in a real browser on the anonymous path — none of the agents had Oxy credentials, and the signed-in path is precisely the one that cannot work.

Two gaps, and the second is the harder one

1. A device-first session records no application. The client knows which application it is (OxyProvider takes a registered clientId), so the identity exists — it is simply not persisted. Note the mint is deliberately public and carries no bearer, and its own comment says it "can be initiated from any registered cross-apex origin over normal CORS" — so on web the origin is a server-derived signal that already maps to a registered application, which is the right shape (derived, not stated by the caller). Native has no Origin, so that alone is not a complete answer.

2. There is no consent moment. follows:write and follows:context:write are USER_CONSENT_REQUIRED_SCOPES — they always require the user to be asked, even for a trusted first-party application, and that rule is the point of #810 rather than an inconvenience. A device-first app has no authorize screen, so there is no app_grants row and nowhere the user was asked.

An in-app SDK consent sheet — shown the first time an application needs a consent-required scope, writing the grant on accept — fits the ecosystem's existing shape, where interactive sign-in is already an in-app modal rather than a redirect. That is a design proposal, not a decision.

What must NOT be the fix

Letting a service credential write to the follow graph. A service token proves which application is calling but not that any user asked it to, and every part of this design refuses that — it is why the capability is derived from a session in the first place.

Blast radius

Server-side everything is live and correct: migrations applied, routes mounted and answering 401 unauthenticated, the outbox worker merged (off by default). The published SDK and button are correct. Three app integrations are merged or open. None of it can be exercised by a signed-in user until this is answered.

Activity

  1. NateIsern commented on Aug 4, 2026

    @NateIsern
    MemberAuthor

    Correction: the central claim of this issue is WRONG

    A real signed-in session in production disproves it. Syra's console:

    POST https://api.oxy.so/v2/follow-targets/namespaces 403 (Forbidden)
    Error: This application has not been granted access to the follow registry
    

    That string is the third branch of requireRegistrar — reached only for no_grant. no_application produces "This session was not created through an application authorization", and that is not what a real user sees.

    So the session did resolve to an application. An auth_sessions row exists and links to it, the application is active, and my reasoning above — that device-first sessions cannot resolve to an application at all — is false.

    How I got it wrong: I traced writers of auth_sessions.authorized_session_id, found one route, observed that the device-first mint is a different route, and concluded the two never meet. I never tested it against a real session. The console output above is one line of evidence and it beats the whole chain of reasoning.

    The actual blocker

    resolveFollowCapability returns no_grant only when no app_grants row exists at all for that (user, application). A row that exists but lacks a scope produces a different, later error naming the scope (Missing scope: follow-targets:register).

    So: the user has never granted this application anything in the follow family — which is correct behaviour, not a bug. follows:write, follows:context:write and the rest are USER_CONSENT_REQUIRED_SCOPES (#810), so they are never auto-approved, not even for a trusted first-party application. Nothing has asked the user yet.

    That makes this much smaller than described above, and it is a wiring problem rather than an architectural one:

    1. The application's registered applications.scopes must include the follow family — that is its ceiling, and migration 0015 widened the CHECK precisely so it could.
    2. The authorization must request those scopes, so the consent screen asks and the grant is recorded.

    What stands from the original text

    Only the last section. Server-side is live and correct, and no signed-in user can follow anything yet. The reason is consent that has never been requested, not a session that cannot carry an application.

    Retitling accordingly.

  2. changed the title [-]The follow graph is unreachable from every first-party app: device-first sessions resolve to no capability[/-] [+]No first-party app has requested follow consent, so every follow call 403s with no_grant[/+] on Aug 4, 2026
  3. NateIsern commented on Aug 4, 2026

    @NateIsern
    MemberAuthor

    Exact diagnosis, traced end to end

    Two records are needed and they come from two different flows, only one of which a first-party app runs:

    record written by do first-party apps run it
    auth_sessions + authorized_session_id (which application) POST /auth/session/create → POST /auth/session/authorize/:sessionToken yes — this is why the session resolves
    app_grants (what the user consented to) POST /auth/oauth/authorize only (recordAppGrant, one call site) no

    resolveFollowCapability needs both. First-party apps get the first and never the second, so every call returns no_grant — which is exactly the error in production.

    Note what this is not: not a broken session model, not a missing column, not device-first being incompatible. The application identity works. The consent record has simply never been created, because nothing has asked.

    Two halves to the fix, and one of them is not code

    1. Registration (operational). An application's scopes are its ceiling, and each app's row must list the follow family before any grant can include it. Migration 0015 widened applications_scopes_check precisely so those values are accepted. Official apps are database rows, not code, so this is a console change per application — not something a deploy does.

    2. A consent path (design decision). follows:write and follows:context:write are USER_CONSENT_REQUIRED_SCOPES (#810): never auto-approved, not even for a trusted first-party application. That rule is the point rather than an obstacle, so the fix cannot be to exempt them.

    Two candidates:

    • (a) Reuse the OAuth authorize flow, once, on first need. First-party apps already have registered redirect URIs, so the flow is available to them. Consent UI, scope validation against the ceiling, and grant recording all already exist and are already correct. Costs one in-app round trip the first time a new scope family is needed. Adds no new trust assumption.
    • (b) A new in-app consent endpoint the SDK drives. Smaller for the user, but the platform would be trusting the application to have actually shown the sheet — the app hosts the UI. That is a weaker assumption than (a), and it is a new one.

    (a) is the recommendation. The ecosystem deleted the /sso bounce for session RESTORE, which happens on every cold boot; a one-time consent for a new permission family is a different thing, and a redirect there is what users expect from a permission prompt. Inventing a parallel consent path to avoid it would trade a well-tested flow for a weaker guarantee, on the exact surface where the guarantee is the feature.

    Until then

    Everything fails closed, verified in Syra: the target never resolves, the button stays disabled, nothing is written and no follow is silently lost. The registration memo clears on failure by design, so each screen view retries — roughly four failed calls per view — which will show in oxy-api logs as 403 volume before the fix lands.

  4. NateIsern commented on Aug 4, 2026

    @NateIsern
    MemberAuthor

    The scope set for step 1, and why a partial one fails in a confusing way

    Whoever adds the follow family to an application's registration needs all of these, not the write ones alone:

    scope why this app needs it
    follows:read the one that is easy to omit — see below
    follows:write follow and unfollow
    follows:context:write "don't show this here" / undo it
    follow-targets:register resolve a target before rendering any control

    follows:manage is deliberately not in that list: it is acting on another application's behalf, which no first-party app should hold.

    Why omitting follows:read produces the worst failure, from Mention's grid: the screen seeds every chip from one batched listFollows({kind:'oxy.topic'}) sweep, which is a read. Without it the grid cannot distinguish "not followed" from "not asked yet", so the chips stay inert by design rather than rendering a wrong state — which is the correct behaviour and also the least diagnosable one. A grant covering only follows:write and follow-targets:register yields a screen that looks broken and does not point at scopes.

    The same applies to any surface that renders state before a press: the read is what makes the control truthful, so it is not optional even for an app that only ever intends to write.

  5. github-actions commented on Nov 30, 2026

    @github-actions

    This issue has been inactive for 60 days. It will be closed in 14 days unless there is new activity.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0