Why am I receiving a 403 error when trying to create a comment using Notion's `/comments` endpoint?

This topic was automatically generated from Slack. You can find the original thread here.

I’m trying to create a comment using Notion (/comments) but it’s returning a 403 error

code: restricted_resource
message: Insufficient permissions for this endpoint.

It looks like you’re encountering a 403 error when trying to create a comment using the Notion API. This error typically means that the API token you’re using does not have the necessary permissions to access the endpoint. Here are a few steps you can take to troubleshoot and resolve this issue: 1. Check OAuth Scopes: Ensure that the OAuth token you’re using has the necessary scopes to create comments. The required scopes for the Notion API can be found in the Notion API documentation. 2. Verify Integration Permissions: Make sure that the integration you created in Notion has the necessary permissions to access the specific page or database where you’re trying to create the comment. You can do this by going to the Notion page or database, clicking on “Share,” and ensuring that your integration is listed with the appropriate permissions. 3. API Request Headers: Ensure that you’re including the correct headers in your API request, including the Authorization header with the Bearer token and the Notion-Version header. Here’s an example Pipedream component that makes a request to create a comment in Notion: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { notion: { type: "app", app: "notion", }, parent_id: { type: "string", label: "Parent ID", description: "The ID of the page or database where the comment will be created", }, comment: { type: "string", label: "Comment", description: "The content of the comment to be created", }, }, async run({ steps, $ }) { return await axios($, { url: `https://api.notion.com/v1/comments`, method: "POST", headers: { Authorization: `Bearer ${this.notion.$auth.oauth_access_token}`, "Notion-Version": `2021-08-16`, }, data: { parent_id: this.parent_id, rich_text: [ { type: "text", text: { content: this.comment, }, }, ], }, }); }, }); Make sure to replace parent_id and comment with the appropriate values. Also, ensure that your integration has the necessary permissions to create

Hi thanks for raising this issue. Looks like the Pipedream Notion Oauth is missing comment scope. I’ll reproduce it and get back to you soon

Thanks! What other scopes are there that it doesn’t have?

I’ve created a ticket here: [OAUTH SCOPE] Notion - Add Comment scope · Issue #12923 · PipedreamHQ/pipedream · GitHub

Thanks! What other scopes are there that it doesn’t have?
Currently we include scopes that required for built-in Pipedream Notion actions. You’ll need to request more scope for your usecase.

have you tried creating a custom OAuth client to use for Notion?

You can define and request whatever scopes you want

I tried but got stuck on the authentication point - may not have done it correctly

Did you see any errors raised during the auth flow? You created the client then tried to connect your account in Pipedream?

Ah I see this error on our end for you:

client_id cannot be blank

Did you skip any fields in the client configuration in Pipedream?

I must’ve - not sure what to put for client ID though. Do I create a public app for Notion?

Yea I believe that’s what you’ll want

Ok let me try this again now that I’m not falling asleep :joy:

I’m seeing a different exception for you in our logs but I think it might be a bug on our end, looking into it.

I managed to get connected… was tinkering around

basically logging into a Notion account in another browser

that’s what the exceptions are on the redirect

Ah okay great!