Zero-dependency nodejs OAuth2 client written in TypeScript. Currently work in progress, not recommended for production use.
npm i easy-oauth2-client
import { ClientCredentials } from 'easy-oauth2-client'
const oauthClient = new ClientCredentials({
authHost: "https://auth.example.org",
clientId: "my-client-id",
clientSecret: "my-client-secret",
})The access token can be obtained using the getToken method and then used in further requests, e.g. when using the request library:
import request from "request"
const token = await oauthClient.getToken()
if (token)
const resource = await request.get("https://api.example.org/protected-resource/", {
auth: {
bearer: token.accessToken,
},
})- Authorization Code
- Implicit
- Resource Owner Password Credentials
- Client Credentials