Minimalistic pre-configured OAuth 2.0 client for Deno. Inspired by grant.

Overview

DenoGrant

Minimalistic pre-configured OAuth 2.0 client for Deno. Inspired by Grant.

NOTE: this is alpha software subject to breaking changes at anytime

  • Comes pre-configured for the following Providers:
  • Built in Typescript definitions for Profile API responses
  • Uses deno-oauth2-client internally
    • can be used with any Deno library
    • only implements OAuth 2.0 grants, letting you take care of storing and retrieving sessions, managing state parameters, etc.

Usage

import DenoGrant, {
  OAuth2Client,
  Providers,
} from "https://deno.land/x/[email protected]/mod.ts";

// Create a DenoGrant instance with your app's base uri and any number of strategies:
const denoGrant = new DenoGrant({
  base_uri: "http://localhost:8000",
  strategies: [{
    provider: Providers.discord,
    client_id: "<your client id>",
    client_secret: "<your client secret>",
    redirect_path: "/auth/discord/callback",
    scope: "identify",
  }, {
    provider: Providers.google,
    client_id: "<your client id>",
    client_secret: "<your client secret>",
    redirect_path: "/auth/google/callback",
    scope: "openid profile",
  }],
});

// You can also add strategies after creation:
const githubStrategy: OAuth2Client = denoGrant.addStrategy(Providers.github, {
  client_id: "<your client id>",
  client_secret: "<your client secret>",
  redirect_path: "/auth/github/callback",
  scope: "",
});

// Generate an authorization URI for a registered strategy:
const discordAuthorizationURI = denoGrant.getAuthorizationUri(Providers.discord)
  .toString();
const googleAuthorizationURI = denoGrant.getAuthorizationUri(Providers.google)
  .toString();
const githubAuthorizationURI = denoGrant.getAuthorizationUri(Providers.github)
  .toString();

// Redirect user to authorization URI...

// User gets redirected back to your app,
// Generate access tokens
const tokens = await denoGrant.getToken(
  Providers.github,
  "http://localhost:8000/auth/github/callback?code=abc123&scope=",
);

// Request user profile with obtained access token
const profile = await denoGrant.getProfile(
  Providers.github,
  tokens.accessToken,
);
// Profile is fully typed based on provider type!
You might also like...

Three.js boilerplate project configured with typescript, webpack and css/style loader, HTTPS local server, and a sample test codes !!

Three.js boilerplate project configured with typescript, webpack and css/style loader, HTTPS local server, and a sample test codes !!

three.js-boilerplate Welcome, this is a three.js boilerplate project where you can clone it and start to work !!! Installed and Configured Items: Type

Jul 6, 2022

A Nextjs-Typescript boilerplate , configured with Tailwindcss, Eslint, Prettier, Lint-staged ,Husky and commitizen

Minimal Nextjs Typescript boilerplate A Minimal Next-Typescript boilerplate to quickly and easily bootstrap your next project. Comes pre-configured wi

Nov 4, 2022

A boilerplate for ExpressJs projects configured with ESLint, Prettier & Airbnb Setup. The boilerplate utilises RESTful architecture and uses Mongodb.

A boilerplate for ExpressJs projects configured with ESLint, Prettier & Airbnb Setup. The boilerplate utilises RESTful architecture and uses Mongodb.

ExpressJs-Boilerplate An ExpressJs boilerplate configured with ESLint, Prettier & Airbnb Setup. The boilerplate utilises RESTful architecture and uses

Mar 8, 2023

A low-feature, dependency-free and performant test runner inspired by Rust and Deno

minitest A low-feature, dependency-free and performant test runner inspired by Rust and Deno Simplicity: Use the mt test runner with the test function

Nov 12, 2022

Cross platform shell tools for Deno inspired by zx.

dax Note: This is very early stages. Just started working on it. Cross platform shell tools for Deno inspired by zx. Differences: No globals or global

Dec 31, 2022

Cross platform shell tools for Deno inspired by zx.

dax Note: This is very early stages. Just started working on it. Cross platform shell tools for Deno inspired by zx. Differences: No globals or global

Jul 24, 2022

This is a simple boilerplate for a Deno website, deployed with Deno Deploy.

Simple Deno Website Boilerplate This is a simple website boilerplate built using Deno and deployed using Deno Deploy. Demo at simple-deno-website-boil

Dec 3, 2022

TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy

Atlas SDK atlas_sdk is a TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy Links Docs Import Replace LATEST_VERSION with current latest versi

Dec 26, 2022

Deno bindings for yoga, using Deno FFI.

deno_yoga Deno bindings for yoga, using Deno FFI. Usage flags: --allow-ffi: Requires ffi access to "yogacore.dll", "libyogacore.so", "libyogacore.dyli

Feb 11, 2022
Comments
Owner
CJ R.
I'm a Full Stack Developer, Educator and Maker. I stream myself teaching and coding on my Twitch and YouTube channel Coding Garden.
CJ R.
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
OAuth 2 / OpenID Connect Client for Web API runtimes

OAuth 2 / OpenID Connect Client for Web APIs runtime This is a collection of bits and pieces upon which a more streamlined Client module may be writte

Filip Skokan 187 Jan 6, 2023
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
Remix Auth plugin for Twitter OAuth 1.0a

Remix Auth Twitter Remix Auth plugin for Twitter OAuth 1.0a. Supported runtimes Runtime Has Support Node.js ✅ Cloudflare ✅ Demo Try out live demo (sou

na2hiro 13 Dec 31, 2022
Express middleware for easy OAuth with a variety of providers.

accounted4 Express middleware for easy OAuth2 with a variety of providers. accounted4 is intended to make it easy for developers to add third-party OA

Josh Moore 3 May 7, 2022
📋 Todo List CRUD and OAuth with Firebase

Todo List CRUD and OAuth with Firebase Esta es una app hecha con React y Firebase en la que puedas crear, leer, actualizar y borrar tareas dentro de u

Adonys Santos 4 May 28, 2022
Empty project with configured webpack, type script and es-lint

Empty project template Empty project with configured webpack, typescript and es-lint Easy to use: Download project files Go to project root directory

Kris Casper 56 Dec 20, 2022
Fullstack Turborepo starter. Typescript, Nestjs, Nextjs, Tailwind, Prisma, Github Actions, Docker, And Reverse proxy configured

Turborepo (NestJS + Prisma + NextJS + Tailwind + Typescript + Jest) Starter This is fullstack turborepo starter. It comes with the following features.

Ejaz Ahmed 132 Jan 9, 2023