Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oslojs/oauth2

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oslojs/oauth2

A runtime-agnostic OAuth 2.0 library

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by3.69%
Maintainers
0
Weekly downloads
 
Created
Source

@oslojs/oauth2

Documentation: https://oauth2.oslojs.dev

A small JavaScript library for parsing OAuth 2.0 token, token revocation, and device authorization responses by Oslo.

This package follows RFC 6749, RFC 7009, and RFC 8628.

  • Runtime-agnostic
  • No third-party dependencies
  • Fully typed
import { TokenRequestResult } from "@oslojs/oauth2";

const response = await fetch("https://github.com/login/oauth/access_token", {
	method: "POST",
	body,
	headers
});
const data = await response.json();
if (typeof data !== "object" || data === null) {
	throw new Error("Unexpected response");
}
const result = new TokenRequestResult(data);
if (result.hasErrorCode()) {
	const error = result.errorCode();
	throw new Error(`Request failed: ${error}`);
}
const accessToken = result.accessToken();
const accessTokenExpiresAt = result.accessTokenExpiresAt();
const refreshToken = result.refreshToken();

Installation

npm i @oslojs/oauth2

Keywords

FAQs

Package last updated on 13 Jul 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc