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

@octokit/auth-oauth-app

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/auth-oauth-app

GitHub OAuth App authentication for JavaScript

  • 8.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
978K
decreased by-13.38%
Maintainers
4
Weekly downloads
 
Created

What is @octokit/auth-oauth-app?

@octokit/auth-oauth-app is an npm package that provides authentication strategies for GitHub OAuth Apps. It allows developers to authenticate users, manage tokens, and handle OAuth flows with ease.

What are @octokit/auth-oauth-app's main functionalities?

Authenticate using OAuth App

This feature allows you to authenticate a user using an OAuth App by exchanging an authorization code for an access token.

const { createOAuthAppAuth } = require('@octokit/auth-oauth-app');

const auth = createOAuthAppAuth({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret'
});

(async () => {
  const { token } = await auth({
    type: 'oauth-user',
    code: 'authorization-code'
  });
  console.log(token);
})();

Check token

This feature allows you to check the validity of an OAuth token by making a request to the GitHub API.

const { createOAuthAppAuth } = require('@octokit/auth-oauth-app');

const auth = createOAuthAppAuth({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret'
});

(async () => {
  const { token } = await auth({
    type: 'oauth-user',
    code: 'authorization-code'
  });
  const { data } = await auth.hook({
    method: 'GET',
    url: '/applications/:client_id/token',
    headers: {
      authorization: `bearer ${token}`
    },
    client_id: 'your-client-id',
    access_token: token
  });
  console.log(data);
})();

Revoke token

This feature allows you to revoke an OAuth token, effectively logging the user out and invalidating the token.

const { createOAuthAppAuth } = require('@octokit/auth-oauth-app');

const auth = createOAuthAppAuth({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret'
});

(async () => {
  const { token } = await auth({
    type: 'oauth-user',
    code: 'authorization-code'
  });
  await auth.hook({
    method: 'DELETE',
    url: '/applications/:client_id/token',
    headers: {
      authorization: `bearer ${token}`
    },
    client_id: 'your-client-id',
    access_token: token
  });
  console.log('Token revoked');
})();

Other packages similar to @octokit/auth-oauth-app

Keywords

FAQs

Package last updated on 16 Apr 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