Arctic

Notion

For usage, see OAuth 2.0 provider.

import { Notion } from "arctic";

const notion = new Notion(clientId, clientSecret, redirectURI);
const url: URL = await notion.createAuthorizationURL(state);
const tokens: NotionTokens = await notion.validateAuthorizationCode(code);

Get user profile

Use the /users/me endpoint.

const tokens = await notion.validateAuthorizationCode(code);
const response = await fetch("https://api.notion.com/v1/users/me", {
	headers: {
		Authorization: `Bearer ${tokens.accessToken}`
	}
});
const user = await response.json();