naoko-auth
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Naoko Auth

Set of functions to achieve authentication in different services such as google, github, etc.

Installation

npm install naoko-auth

Quick start

const { Github } = require("naoko-auth");

const github = new Github({
  redirectUri: process.env.GITHUB_REDIRECT_URI,
  clientId: process.env.GITHUB_CLIENT_ID,
  clientSecret: process.env.GITHUB_CLIENT_SECRET,
});

app.get("/auth/github", async (req, res) => {
  const { url } = await github.create();
  res.redirect(url);
});

app.get("/auth/callback/github", async (req, res) => {
  const { code } = req.query;
  if (!code) res.status(400).json({ message: "Code is required." });
  const data = await github.callback(code);
  console.log({ data });
  res.redirect(url);
});

app.get("/success", async (req, res) => {
  res.json({
    success: true,
  });
});

app.listen(3000);

Package Sidebar

Install

npm i naoko-auth

Weekly Downloads

4

Version

0.0.3

License

MIT

Unpacked Size

15.1 kB

Total Files

7

Last publish

Collaborators

  • aizawa-san