From 6b01ab47972c5197ea29723efc0a5e9071836fce Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Mon, 5 Jan 2026 18:13:32 -0500 Subject: [PATCH 1/2] feat(oauth): add `Notion` OAuth provider --- packages/core/src/oauth/index.ts | 3 ++ packages/core/src/oauth/notion.ts | 52 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 packages/core/src/oauth/notion.ts diff --git a/packages/core/src/oauth/index.ts b/packages/core/src/oauth/index.ts index 64e0397..96d751e 100644 --- a/packages/core/src/oauth/index.ts +++ b/packages/core/src/oauth/index.ts @@ -12,6 +12,7 @@ import { gitlab } from "./gitlab.js" import { spotify } from "./spotify.js" import { x } from "./x.js" import { strava } from "./strava.js" +import { notion } from "./notion.js" export { github, type GitHubProfile } from "./github.js" export { bitbucket, type BitbucketProfile } from "./bitbucket.js" @@ -21,6 +22,7 @@ export { gitlab, type GitLabProfile } from "./gitlab.js" export { spotify, type SpotifyProfile } from "./spotify.js" export { x, type XProfile } from "./x.js" export { strava, type StravaProfile, type SummaryClub, type SummaryGear } from "./strava.js" +export { notion, type NotionProfile, type Bot, type Owner, type Person, type User } from "./notion.js" export const builtInOAuthProviders = { github, @@ -31,6 +33,7 @@ export const builtInOAuthProviders = { spotify, x, strava, + notion, } const defineOAuthEnvironment = (oauth: string) => { diff --git a/packages/core/src/oauth/notion.ts b/packages/core/src/oauth/notion.ts new file mode 100644 index 0000000..f9b50e6 --- /dev/null +++ b/packages/core/src/oauth/notion.ts @@ -0,0 +1,52 @@ +import { OAuthProviderConfig } from "@/@types/index.js" + +export interface Person { + email: string +} + +export interface User { + object: "user" + id: string + name: string + avatar_url: string | null + type: "person" + person: Person +} + +export interface Owner { + type: "user" + user: User +} + +export interface Bot { + owner: Owner +} + +/** + * @see [Notion - Retrieve your token's bot user](https://developers.notion.com/reference/get-self) + */ +export interface NotionProfile { + object: "user" + id: string + name: string + avatar_url: string | null + type: "bot" + bot: Bot +} + +/** + * @see [Notion - Developer Documentation](https://developers.notion.com/) + * @see [Notion - Authorization](https://developers.notion.com/docs/authorization) + * @see [Notion - Authentication](https://developers.notion.com/reference/authentication) + * @see [Notion - Retrieve your token's bot user](https://developers.notion.com/reference/get-self) + * @todo: It's required to pass the Notion-Version header to access the user info endpoint. + */ +export const notion: OAuthProviderConfig = { + id: "notion", + name: "Notion", + authorizeURL: "https://api.notion.com/v1/oauth/authorize?owner=user", + accessToken: "https://api.notion.com/v1/oauth/token", + userInfo: "https://api.notion.com/v1/users/me", + scope: "user:read", + responseType: "code", +} From d7a6f0e36e46ffcda559b3520d4baf59d30ca929 Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Mon, 5 Jan 2026 18:38:22 -0500 Subject: [PATCH 2/2] docs(notion): highlight future implementations --- packages/core/src/oauth/notion.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/core/src/oauth/notion.ts b/packages/core/src/oauth/notion.ts index f9b50e6..9a9c1b8 100644 --- a/packages/core/src/oauth/notion.ts +++ b/packages/core/src/oauth/notion.ts @@ -40,6 +40,9 @@ export interface NotionProfile { * @see [Notion - Authentication](https://developers.notion.com/reference/authentication) * @see [Notion - Retrieve your token's bot user](https://developers.notion.com/reference/get-self) * @todo: It's required to pass the Notion-Version header to access the user info endpoint. + * headers: { Notion-Version: "2022-06-28" } + * @todo: It's required to add Basic headers for access token request. + * headers: { Authorization: "Basic base64(client_id:client_secret)" } */ export const notion: OAuthProviderConfig = { id: "notion", @@ -49,4 +52,12 @@ export const notion: OAuthProviderConfig = { userInfo: "https://api.notion.com/v1/users/me", scope: "user:read", responseType: "code", + profile(profile) { + return { + sub: profile.id, + name: profile.name, + image: profile.avatar_url ?? "", + email: profile?.bot?.owner?.user?.person?.email, + } + }, }