Integration OAuth in Sume: 10-minute state, one claim, admin recheck

Sume's connector OAuth state is random, user-bound and valid ten minutes. A cookie binds the browser, one callback claims it, and admin rights are rechecked.

5 min readSume
All posts

When you click Connect on a Sume integration, the OAuth state is random, tied to your user and workspace, and valid for ten minutes. An httpOnly, SameSite=Lax cookie binds the browser. The callback claims the state exactly once, checks again that you are an admin of the original workspace, then exchanges the code with PKCE and saves the token.

Step by step

  • Connect creates a random, ten-minute, user-bound and workspace-bound state, and sets the cookie.
  • The provider sends the browser to /api/integrations/{provider}/callback.
  • The callback atomically claims the state; a second use finds nothing.
  • It validates admin membership again for the original workspace, not the currently selected Clerk organization.
  • It exchanges the code with PKCE, discovers the permitted tools and saves the encrypted token.

Why the admin recheck matters

A person can lose admin rights, or switch organizations, while a consent screen is open. Checking at the callback against the workspace that started the flow stops a stale tab from granting access to the wrong place.

Why single claim

The callback must find the same pending transaction to complete. A disconnect, a new connect attempt or a switch to a demo removes or replaces it, so an old authorization cannot be resurrected later.

Return path

Sume derives the return path itself and never accepts one from a client. That avoids an open-redirect style abuse of the callback.

What you can do about it

If a Connect attempt fails or you waited too long on the provider screen, start over from the Integrations page; the old state is gone either way. For the client-side rules of Sume's hosted MCP login, which is a different OAuth server, see PKCE S256 only and the MCP OAuth flow.

Failure modes you may see

If you take more than ten minutes at the consent screen, the callback finds no valid state and the connect does not complete. If you open the callback in a different browser, the cookie binding fails. If you clicked Connect twice, only the latest pending transaction can complete.

None of these are bugs. They are the checks that keep a stolen or stale callback URL from attaching a provider account to a workspace.

Related posts

More in Integrations

All Integrations posts

Written by Sume