Repository navigation
Allow managed OAuth clients without scopes and with HTTP Basic revocation - #467
Merged
Merged
Conversation
…tion Some services decide a client's access in its registration and take no scopes, such as Notion. A managed client may now list no scopes, and an authorization without scopes is accepted only for such a client, so a server cannot grant its default scopes to a client with a scope policy. `revocationAuthentication: "basic"` revokes grants with the client's credentials in HTTP Basic authentication instead of the form, which Notion's revocation endpoint requires. Without it, revocation keeps sending them in the form.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 4623b5b | Nov 28 2026, 05:27 PM |
…TTP Basic - `revocationEndpointAuthMethod` (`client_secret_post` or `client_secret_basic`) replaces `revocationAuthentication`. Only registered clients take it, and only with a revocation URL; public metadata document clients have no secret to authenticate with. - Only registered clients may list no scopes. A metadata document client without scopes could receive the server's defaults. - The Better Auth core patch refreshes Notion tokens with HTTP Basic client authentication, the only kind Notion's token endpoint accepts. Better Auth's Notion provider sends the credentials in the form on refresh. - Tests check how each request authenticates: Notion's code exchange, refresh and revocation with HTTP Basic, and revocation with the credentials in the form by default.
Notion revokes an access token and the tokens issued before it, and answers a refresh token without revoking anything (checked against Notion).
Each exchange and refresh in the test issues a new access token, and the test revokes the one from the refresh, as the Notion template does. The schema says what a client without scopes is granted.
tnkuehne
added a commit
that referenced
this pull request
Nov 28, 2026
## Change **A Notion template.** - 61 methods for Notion's API in version `2026-03-11`, generated from Notion's published OpenAPI description (`https://developers.notion.com/openapi.json`): - users, search, pages, page properties and page Markdown, async tasks - blocks, databases, data sources, data source templates, views and view queries - comments, file uploads, custom emojis, AI meeting notes from recordings - Custom Agents, their sessions and events, Agent Skills plugins and skills - `streamSessionMessage` sends a session message with `Accept: text/event-stream` and answers with the turn's events (`session.snapshot`, `event.provisional`, `event.committed`, `stream.timeout`, `stream.end`, `stream.error`), and replays a turn from a committed event with `continue_from`. - `getPageProperty` sends property IDs as Notion returned them, URL-encoded. - Every method takes an optional `notionBeta` for Notion's opt-in betas, such as `status-group-filters-2026-10-06`. - Not offered, because they do not work with the person's OAuth token: - the OAuth endpoints, which take the OAuth client's credentials - deleting a Custom Agent, changing its credit limit, creating a full-page meeting note and linking it to a calendar event, which take a personal access token or a Notion Worker - Notion's Admin API, which takes an organization bot token - `updateAgentStatus` offers the deprecated agent status endpoint, which Notion still serves. - Errors keep Notion's `code`, `message`, `request_id` and `additional_data`. A write that was saved although its answer timed out returns its `retry_guidance` and `committed_resource_id`. - 429 and 529 return `rate_limited` with `Retry-After`. A connection Notion blocked (`public_api_request_blocked`) returns Notion's error instead. **Connection.** - Each person connects their own Notion account through Better Auth's Notion provider and chooses the pages to share in Notion's page picker. - An installation's managed `notion` client is used when present; it needs #467, which this PR builds on. Otherwise the app asks for `NOTION_CLIENT_ID` and `NOTION_CLIENT_SECRET` of the organization's own OAuth integration. **Generator.** - A header the description requires with one allowed value, such as `Notion-Version`, is sent on every request instead of being an input (`fixedHeaders`). The generated types describe that version. - A fixed header's value may come from a referenced schema. - `encodedPathParameters` names path parameters the API hands out URL-encoded; the runtime sends them as they are when they hold only unreserved characters and percent escapes. - A union lists no string values next to a named type of any string, such as Notion's `IdRequest | "notion_ai"`. - The shared `rest.ts` sends the fixed headers; the other REST templates get the updated copy. ## Screenshots The connection page. The favicon is Notion's own icon from notion.com. | | Setup required | Not connected | Connected | | --- | --- | --- | --- | | 1280 px, light | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-setup-1280-light.png" width="300"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-disconnected-1280-light.png" width="300"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-connected-1280-light.png" width="300"> | | 1280 px, dark | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-setup-1280-dark.png" width="300"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-disconnected-1280-dark.png" width="300"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-connected-1280-dark.png" width="300"> | | 390 px, light | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-setup-390-light.png" width="200"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-disconnected-390-light.png" width="200"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-connected-390-light.png" width="200"> | | 390 px, dark | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-setup-390-dark.png" width="200"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-disconnected-390-dark.png" width="200"> | <img src="https://gist.githubusercontent.com/tnkuehne/bf81b61359b40ebba014f4afc27b9e20/raw/23f5391258f5facd642e016683944febd7721518/notion-connected-390-dark.png" width="200"> | Not shown: the connection error alert. ## Tests - Template tests: streamed session turns, encoded property IDs, connection, Notion-Version and Notion-Beta headers, cursor pages, user and issuer isolation, approvals, multipart uploads with binary bytes, reconnecting the same Notion user, Notion's errors, rate limits, overload and saved-but-timed-out writes. - Managed OAuth tests for the Notion client: authorization, exchange, refresh and revocation with HTTP Basic client authentication. - Generator tests for fixed headers, referenced header schemas, encoded path parameters and unions with named string types. - `pnpm check`, all template tests, the generator tests and the app runtime's OAuth tests. - Regenerating from the downloaded description reproduces the committed files. **Live against Notion** (an OAuth integration in a workspace on the free plan): - Connecting through OAuth with the organization's own client. - Users, search, pages, page properties, page Markdown and async tasks, blocks, databases, data sources, views and view queries, comments, single-part file uploads, custom emojis, Agent Skills plugin listing and download. Test data with non-ASCII text and a PNG with binary bytes, which downloaded identically. - `getPageProperty` with property IDs as Notion returned them, URL-encoded (`%5BT%40s`, `%3BaJY`, `%5CCab` and others), for every property type of a test database, with non-ASCII names and values. Notion also accepts the IDs encoded a second time; the template sends them as Notion's reference and SDK do. - Refresh and revocation with HTTP Basic, and their rejection with credentials in the form. Notion revokes an access token and the tokens issued before it, and answers a refresh token without revoking anything, so disconnecting revokes the current access token; afterwards every access and refresh token of the grant is rejected. A revoked token returns `reconnect_required`. **Not run live**, because the test workspace does not offer them: - Custom Agents and sessions: the test integration had no agent capabilities (403). - `uploadSkill`: the workspace's only skill is in use. - Multi-part uploads (`completeFileUpload`) and `createMeetingNote`: not available on the free plan. - The managed client, which the hosted installation configures after this is released.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Clients without scopes.
"scopes": []), for services that decide a client's access in its registration, such as Notion, whose integration's capabilities and the pages a person selects decide access.scopeparameter, a server may grant its own default scopes (RFC 6749 §3.3).Revocation method.
revocationEndpointAuthMethodnames how a registered client authenticates at itsrevocationUrl, with RFC 8414's method names:client_secret_post, the default, orclient_secret_basic. It requires arevocationUrl. Metadata document clients have no secret and do not take it.client_secret_basic, the credentials go in HTTP Basic authentication, encoded as Better Auth encodes them for token requests, and the form carries only the token.invalid_clientwhen the credentials are in the form and revokes with HTTP Basic (checked against Notion with a real OAuth integration).Notion refresh.
invalid_client(checked against Notion). The broker refreshes through that provider.Tests
scopeparameter, rejected requested scopes, and code exchange, refresh and revocation of the access token each authenticated with HTTP Basic and without credentials in the form, against a mock that rejects any other authentication.pnpm check, the broker tests and the managed OAuth tests of the templates.