Git Product home page Git Product logo

notion-oauth-pkce's Introduction

Notion OAuth PKCE Proxy

This is a Notion OAuth PKCE proxy built with Next.js.

Currently, the Notion API does not support PKCE entirely, so the only solution to use OAuth with your app is using a proxy like this.

The proxy server has been designed to follow the auth flow detailed on this page. It may need some tweaks to adapt it to your use case, so use it as an starting point.

Configuration

Create an .env.local file using the environment variables from the .env.template and fill in your own values.

Here is an example using Notion Assignment Import as the client:

CLIENT_ID=Notion OAuth Client ID
CLIENT_SECRET=Notion OAuth Client Secret
PROXY_REDIRECT_URL=https://oauth.jamesnzl.xyz/api/notion/code
CLIENT_REDIRECT_URL=https://oauth.jamesnzl.xyz/api/notion/access-token
NOTION_AUTHORIZE_URL=https://api.notion.com/v1/oauth/authorize
NOTION_TOKEN_URL=https://api.notion.com/v1/oauth/token
REDIRECT_URIS=https://elbkjcjgakaoccocmbglokgmalkoacie.chromiumapp.org/oauth, https://7e9f954a96941fe75f6a7ebc65e530350aafaf53.extensions.allizom.org/oauth

The redirect_uri of your app, to which to send the temporary code grant, must be prelimiarily registered in REDIRECT_URIS to prevent open redirector attacks.
This is a , delimited list, to accomodate use cases where your app may have a number of different redirect URLs.
The redirect_uri must be entered exactly as it will be passed to /api/notion/authorise, and does not support pattern matching for security reasons.

Run locally

To run the proxy locally start the project with the following commands:

npm run dev
# or
yarn dev

After that you may want to expose your localhost using Ngrok or a similar service to test your integration.

Deploy on Vercel

The easiest way to deploy the proxy is using Vercel from the creators of Next.js.

github-banner

Licence

The source code of this repository is licensed under MIT.

notion-oauth-pkce's People

Contributors

dependabot[bot] avatar jamesnzl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.