Elysia plugin for OAuth 2.0 Authorization Flow.
Powered by Arctic with more than 48 oauth2 providers!
bun install elysia-oauth2 arctic
if Arctic will release some new providers, you can update it with
bun install arctic@latest
import { Elysia } from "elysia";
import { oauth2 } from "elysia-oauth2";
new Elysia()
.use(
oauth2({
VK: [
"clientID",
"clientSecret",
"https://example.com/auth/vk/callback",
],
})
)
.get("/auth/vk", ({ oauth2 }) => oauth2.redirect("VK"))
.get("/auth/vk/callback", async ({ oauth2 }) => {
const token = await oauth2.authorize("VK");
// send request to API with token
})
.listen(3001);
import { Elysia } from "elysia";
import { oauth2 } from "elysia-oauth2";
new Elysia()
.use(
oauth2({
Google: [
"clientID",
"clientSecret",
"https://example.com/auth/Google/callback",
],
})
)
.get("/auth/google", ({ oauth2, redirect }) => {
const url = await oauth2.createURL("Google");
url.searchParams.set("access_type", "offline");
return redirect(url.href);
})
.get("/auth/google/callback", async ({ oauth2 }) => {
const token = await oauth2.authorize("Google");
// send request to API with token
})
.listen(3001);
- 42 School
- Amazon Cognito
- AniList
- Apple
- Atlassian
- Auth0
- Authentik
- Bitbucket
- Box
- Coinbase
- Discord
- Dribbble
- Dropbox
- Figma
- Github
- GitLab
- Intuit
- Kakao
- Keycloak
- Lichess
- Line
- Linear
- Microsoft Entra ID
- MyAnimeList
- Notion
- Okta
- osu!
- Patreon
- Roblox
- Salesforce
- Shikimori
- Slack
- Spotify
- Strava
- Tiltify
- Tumblr
- Twitch
- VK
- WorkOS
- Yahoo
- Yandex
- Zoom