Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 04:45 UTC
How do I set up custom OAuth credentials for Notion?
Use your own Notion integration when you want your own name and logo on the consent screen and in Notion's activity, or to keep your users' tokens isolated to your product.
Create the Notion integration
- Go to Notion integrations and click New integration.
- Enter a name, such as
Composio Notion Integration, and select the associated workspace. - Set the integration type to Public. Composio's OAuth flow requires a public integration.
- Under OAuth domains & URIs, add the redirect URI
https://backend.composio.dev/api/v1/auth-apps/add. Use it exactly as shown: HTTPS, no trailing slash, no fragments or wildcards. It must exactly match theoauth_redirect_urifield in your Composio auth config. - Under Capabilities, select only what your integration needs, such as Read content, Update content, Insert content, and Read user information. Notion uses capabilities instead of OAuth scopes.
6. Save, then copy the Client ID and Client Secret.

Create the auth config in Composio
- In the Composio dashboard, go to Auth Configs, click Create Auth Config, and select Notion.

2. Set the authentication type to OAuth2 and choose Use your own developer authentication.
3. Paste the Client ID and Client Secret and click Create Notion Auth Config. Leave scopes empty.
4. Click Connect Account, choose the pages to share during Notion's authorization, and confirm the account shows as Active.
See Custom auth configs for the general flow.
How do I connect Notion with an API key?
Use an internal integration secret when you connect your own workspace, don't need multi-user OAuth, and want to skip the redirect flow. API keys only work with internal integrations; public integrations must use OAuth.
- On Notion integrations, click New integration, enter a name, select the workspace, and set the type to Internal.
- Copy the integration secret. It starts with
ntn_orsecret_. - Share the pages and databases you want Composio to reach with the integration. The integration can only access pages shared with it.
- In the Composio dashboard, create a Notion auth config with the API Key auth type. Click Connect Account, paste the secret, and confirm the account shows as Active.


Why do Notion operations show "Composio" instead of the user's name?
Notion attributes actions to the integration itself, not the individual user. The name and logo shown come from the integration configuration. To use a custom name or logo, create your own Notion integration. See Notion integration docs.
How do I grant access to more Notion pages?
Open Notion, go to Settings & Members, then Connections. Select the integration (Composio or your custom integration), click "Select pages" or "Manage access", and add or remove pages as needed.
Does Notion use OAuth scopes?
No. Notion controls access by granting integrations access to specific pages and databases, not through scopes. You don't need to pass scopes when creating an auth config.
How does Notion's access model work?
It depends on the integration type. OAuth apps (public) let users select which pages to share during authorization. Internal integrations (API key) have page access managed in the integration settings.
Reasons for Notion Connection expiry
The user disconnects the integration from Notion. Notion documents that OAuth-installed public connections appear under
Settings->Connectionsand can be disconnected from the workspace. If a user removes the Composio-managed or custom Notion app there, the existing token set should be treated as revoked, and the user should reconnect Notion. See Notion's official guide to adding and managing workspace connections.The same Notion user connects again through the same Notion app. When a Notion user connects to a Notion app, Notion issues a new
access_tokenandrefresh_tokenpair for that connection. If the same user connects to the same Notion app again, whether it is Composio-managed or custom, Notion can issue a new token pair and invalidate the olderrefresh_token. The olderaccess_tokenmay continue working for some time, but once it expires, the older connection can no longer refresh and should be treated as expired. To avoid this, keep one active Notion connection per real user for a given Notion app, reuse that existing connection in your product, and avoid asking users to reconnect repeatedly. For production Notion integrations, we strongly recommend using your own Notion app so your users' tokens are isolated to your product. See "How do I set up custom OAuth credentials for Notion?" on this page for the steps.
How do I set up the Notion webhook ingress endpoint?
With Composio-managed Notion credentials, the webhook ingress endpoint is already provisioned, so just create the trigger. If you bring your own Notion OAuth app, the verification flow runs in reverse from Slack's: Notion sends a verification token to the ingress endpoint, and you paste that token back into Notion to finalize.
Create the endpoint
Python
from composio import Composio
composio = Composio()
endpoint = composio.webhooks.endpoints.create(
toolkit_slug="notion",
client_id="YOUR_NOTION_OAUTH_CLIENT_ID",
)
print(endpoint.root.id, endpoint.root.webhook_url)
TypeScript
import { Composio } from '@composio/core';
const composio = new Composio();
const endpoint = await composio.webhooks.endpoints.create({
toolkitSlug: 'notion',
clientId: 'YOUR_NOTION_OAUTH_CLIENT_ID',
});
console.log(endpoint.id, endpoint.webhookUrl);
API
curl -X POST https://backend.composio.dev/api/v3.1/webhook_endpoints \
-H "x-api-key: $COMPOSIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"toolkit_slug": "notion", "client_id": "YOUR_NOTION_OAUTH_CLIENT_ID"}'
Complete Notion verification
Save the returned id and webhook_url. Paste webhook_url into your Notion integration's Webhook settings. Notion sends a verification token to that URL.
Replace we_123 with the saved endpoint ID and read the token:
Python
from composio import Composio
composio = Composio()
endpoint = composio.webhooks.endpoints.get("we_123")
token = endpoint.data.get("webhook_signing_secret") if endpoint.data is not None else None
if token is None:
raise RuntimeError("Notion has not sent a verification token yet")
print(token)
TypeScript
import { Composio } from '@composio/core';
const composio = new Composio();
const endpoint = await composio.webhooks.endpoints.get('we_123');
const token = endpoint.data?.webhook_signing_secret;
if (token == null) throw new Error('Notion has not sent a verification token yet');
console.log(token);
API
curl -s https://backend.composio.dev/api/v3.1/webhook_endpoints/we_123 \
-H "x-api-key: $COMPOSIO_API_KEY" | jq -er '.data.webhook_signing_secret // error("Notion has not sent a verification token yet")'
Paste the token back into Notion's verify field to complete setup. Continue with Creating triggers.
Notion database trigger fires for new pages, not updates
In manual testing, the Notion trigger fired when pages were added to the watched database, but not for updates. Test by adding a new page to the target database.