notion-sdk-js icon indicating copy to clipboard operation
notion-sdk-js copied to clipboard

OAuth support?

Open justjake opened this issue 4 years ago • 2 comments

How do I use the SDK to complete the oauth flow?

justjake avatar May 18 '21 03:05 justjake

Do you mean how you authorize? Head over to https://www.notion.so/my-integrations and create a new integration and paste the token into the client.

muuvmuuv avatar May 23 '21 08:05 muuvmuuv

@muuvmuuv I am referring to the OAuth flow for public integrations which involves sending a POST request to https://api.notion.com/v1/oauth/token

justjake avatar Jun 09 '21 04:06 justjake

For future searchers, although lacking OAuth functions from this library is apparently a miss, implementing it, for example with Express, can be fairly straight forward since it's not OAuth2. You redirect your user to the /oauth/authorize endpoint, having them allow access, and Notion redirects user's browser back to your redirect_uri so you can use the code to call /oauth/token for the access token which represents the user. And this wraps up the whole process. Currently Notion API doesn't require you to encrypt or decrypt anything which is way easier than many other OAuth providers.

This is not the most accurate description of the OAuth process but you get the gist. Also you can follow this article if you just want some working code https://naomiperez.netlify.app/notion-oauth-flow/

mogita avatar Mar 11 '23 15:03 mogita

Hi @mogita Could you please share the that repo? I'm currently working on a project which require notion public integration. I've done with internal integration by specify certain pages but get stuck with public integration(OAuth 2). I'm looking forward to your reply.

cooljameswei avatar Apr 12 '23 19:04 cooljameswei

/v1/oauth/token has now been incorporated into the SDK as of v2.2.11 🎉

rhart92 avatar Aug 14 '23 20:08 rhart92