@uveysservetoglu/kobil-auth
v1.0.0
Published
KOBIL OIDC (OpenID Connect) authentication helper for Node.js: build authorization URLs and exchange authorization codes for tokens.
Downloads
139
Maintainers
Readme
@uveysservetoglu/kobil-auth
KOBIL OIDC (OpenID Connect) authentication helper for Node.js / TypeScript.
- Build authorization redirect URLs with a secure random nonce
- Exchange authorization codes for tokens
npm install @uveysservetoglu/kobil-authimport { AuthClient } from "@uveysservetoglu/kobil-auth";
const auth = new AuthClient({
authorizationEndpoint: process.env.OAUTH_URL!,
tokenEndpoint: process.env.OTOKEN_URL!,
clientId: process.env.OAUTH_CLIENT_ID!,
clientSecret: process.env.OAUTH_CLIENT_SECRET!,
scope: "openid profile email",
});
// 1. Redirect the user to log in
const url = auth.buildAuthorizationUrl("https://app.example.com/callback");
// 2. On the callback, exchange the code
const tokens = await auth.exchangeCodeForToken(code, "https://app.example.com/callback");JavaScript usage is identical (const { AuthClient } = require("@uveysservetoglu/kobil-auth")).
Failures throw KobilAuthError (extends KobilError from @uveysservetoglu/kobil-core), carrying
statusCode and responseBody when available.
License
MIT
