Socket
Book a DemoInstallSign in
Socket

churros-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

churros-client

The official OAuth2 client for [Churros](https://churros.inpt.fr).

0.1.0
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

churros-client

The official OAuth2 client for Churros.

Setup

Create an app on Churros developers and get your client ID and secret.

Usage

An example with Express:

import { ChurrosClient } from '@inp-net/churros-client';
import express from 'express';

const churros = new ChurrosClient({
  client_id: 'your client id',
  client_secret: 'your client secret',
  // where you want to redirect the user after login
  redirect_uri: 'http://localhost:3000/callback',
});

const yourApp = express();

yourApp.get('/login', (_, res) => {
  res.redirect(churros.authorizationURL);
});

yourApp.get(churros.redirectURL.pathname, async (req, res) => {
  if (req.query['error']) {
    // Handle error
    res.sendStatus(500);
  }
  const token = await churros.getToken(req.query['code'], req.query['state']);

  // Do something with the token, for example get some user info,
  // or use the GraphQL API for everything else (see https://churros.inpt.fr/graphql in your browser)
  const userInfo = await fetch('https://churros.inpt.fr/identity', {
    headers: {
      Authorization: `Bearer ${token}`,
    },
  });

  res.status(200).json(await userInfo.json());
});

console.info('Listening on http://localhost:3000');
yourApp.listen(3000);

Go to /login to start the process.

FAQs

Package last updated on 06 Jan 2024

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.