NotionX / react-notion-x

Fast and accurate React renderer for Notion. TS batteries included. ⚡️
https://react-notion-x-demo.transitivebullsh.it
MIT License
4.75k stars 552 forks source link

feat(notion-client): support notion internal integration token(secret) #463

Closed LetTTGACO closed 1 year ago

LetTTGACO commented 1 year ago

Description

👏 Support using notion internal integration token

If I don't want my notion page to be shared, but I still want to get it. in the current version, i can use authToken in the request cookie, but the authToken has a maximum expiration time of 180 days. In fact, there is another way, which is to use notion internal integration token in my-integrations page, I can generate a internal integration token, and then use it in the request header. so, i copyed @notionhq/client's code to notion-client

private authAsHeaders(auth?: string): Record<string, string> {
  const headers: Record<string, string> = {}
  const authHeaderValue = auth ?? this.#auth
  if (authHeaderValue !== undefined) {
    headers["authorization"] = `Bearer ${authHeaderValue}`
  }
  return headers
}

Notion Test Page ID

notion page id is not needed here

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-notion-x ✅ Ready (Inspect) Visit Preview Apr 8, 2023 5:56pm
react-notion-x-minimal-demo ✅ Ready (Inspect) Visit Preview Apr 8, 2023 5:56pm