Socket
Socket
Sign inDemoInstall

remix-auth-notion

Package Overview
Dependencies
25
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remix-auth-notion

Allow users to login with Notion.


Version published
Weekly downloads
7
increased by250%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

NotionStrategy

Allow users to login with Notion.

Setup your application at Notion integrations The integration should be setup as Public integration

Copy OAuth client ID and OAuth client secret to your NotionStrategy setup and setup the Redirect URI.

Notion requires that the redirect URI uses HTTPS. In development you can use a service like ngrok to be able to test the integration.

Supported runtimes

RuntimeHas Support
Node.js
Cloudflare

How to use

let notionStrategy = new NotionStrategy(
  {
    clientID: "",
    clientSecret: "",
    callbackURL: "https://domain-name.com/auth/notion/callback",
  },
  async ({ accessToken, extraParams, profile }) => {
    return {
      accessToken,
      id: profile.id,
      name: profile.name,
    };
  }
);

authenticator.use(notionStrategy);

In routes/auth/notion.tsx

import { ActionFunction, LoaderFunction, redirect } from "remix";
import { authenticator } from "~/auth.server";

export let loader: LoaderFunction = () => redirect("/login");

export let action: ActionFunction = ({ request }) => {
  return authenticator.authenticate("notion", request);
};

In routes/auth/notion/callback.tsx

import { ActionFunction, LoaderFunction, redirect } from "remix";
import { authenticator } from "~/auth.server";

export let loader: LoaderFunction = async ({ request }) => {
  return authenticator.authenticate("notion", request, {
    successRedirect: "/success",
    failureRedirect: "/login",
  });
};

Now you can direct the user to login by making a Form with POST to /auth/notion

import { Form } from "remix";

export default function Index() {
  return (
    <Form action="/auth/notion" method="post">
      <button>Login with Notion</button>
    </Form>
  );
}

Keywords

FAQs

Last updated on 11 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc