All Projects β†’ octokit β†’ Auth.js

octokit / Auth.js

Licence: mit
GitHub API authentication library for JavaScript and Node.js

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Auth.js

Pytest Picked
Run the tests related to the changed files (according to Git) πŸ€“
Stars: ✭ 262 (-1.87%)
Mutual labels:  hacktoberfest
Commands
Java Command Dispatch Framework - (Bukkit, Spigot, Paper, Sponge, Bungee, JDA, Velocity supported, generically usable anywhere)
Stars: ✭ 266 (-0.37%)
Mutual labels:  hacktoberfest
Wp Graphql
πŸš€ GraphQL API for WordPress
Stars: ✭ 3,097 (+1059.93%)
Mutual labels:  hacktoberfest
Jackson Databind
General data-binding package for Jackson (2.x): works on streaming API (core) implementation(s)
Stars: ✭ 2,959 (+1008.24%)
Mutual labels:  hacktoberfest
Foremast
Spinnaker Pipeline/Infrastructure Configuration and Templating Tool - Pipelines as Code.
Stars: ✭ 263 (-1.5%)
Mutual labels:  hacktoberfest
Community.general
Ansible Community General Collection
Stars: ✭ 266 (-0.37%)
Mutual labels:  hacktoberfest
Pine64 Arch
PKGBUILD for running Arch Linux on PinePhone/PineTab.
Stars: ✭ 258 (-3.37%)
Mutual labels:  hacktoberfest
Cpp
Repository for C++/C codes and algos.
Stars: ✭ 265 (-0.75%)
Mutual labels:  hacktoberfest
Noice
A native Android app to relax, improve focus and boost productivity with minimal background noise.
Stars: ✭ 264 (-1.12%)
Mutual labels:  hacktoberfest
Fl chart
A powerful Flutter chart library, currently supporting Line Chart, Bar Chart, Pie Chart, Scatter Chart and Radar Chart.
Stars: ✭ 3,882 (+1353.93%)
Mutual labels:  hacktoberfest
Awesome Remote Work
😎 Awesome lists about remote work
Stars: ✭ 264 (-1.12%)
Mutual labels:  hacktoberfest
Javascript Cheatsheet
Basic Javascript Cheat Sheet
Stars: ✭ 262 (-1.87%)
Mutual labels:  hacktoberfest
Ajsf
Angular JSON Schema Form
Stars: ✭ 266 (-0.37%)
Mutual labels:  hacktoberfest
Ddh
A fast duplicate file finder
Stars: ✭ 262 (-1.87%)
Mutual labels:  hacktoberfest
Deepchem
Democratizing Deep-Learning for Drug Discovery, Quantum Chemistry, Materials Science and Biology
Stars: ✭ 3,324 (+1144.94%)
Mutual labels:  hacktoberfest
Cpp
Implementation of All β–²lgorithms in C++ Programming Language
Stars: ✭ 263 (-1.5%)
Mutual labels:  hacktoberfest
Ac Music Extension
Google Chrome extension that plays hourly Animal Crossing music and more while browsing!
Stars: ✭ 262 (-1.87%)
Mutual labels:  hacktoberfest
Toha
A Hugo theme for personal portfolio
Stars: ✭ 267 (+0%)
Mutual labels:  hacktoberfest
Ultimate Python
Ultimate Python study guide for newcomers and professionals alike. 🐍 🐍 🐍
Stars: ✭ 3,309 (+1139.33%)
Mutual labels:  hacktoberfest
Termonad
Terminal emulator configurable in Haskell.
Stars: ✭ 266 (-0.37%)
Mutual labels:  hacktoberfest

auth.js

GitHub API authentication library for browsers and Node.js

@latest Build Status

GitHub supports 4 authentication strategies. They are all implemented in @octokit/auth.

Example usage

Browsers

Load @octokit/auth directly from cdn.skypack.dev

<script type="module">
  import {
    createAppAuth,
    createOAuthAppAuth,
    createTokenAuth,
  } from "https://cdn.skypack.dev/@octokit/auth";
</script>
Node

Install with npm install @octokit/auth

const {
  createAppAuth,
  createOAuthAppAuth,
  createTokenAuth,
  createActionAuth,
} = require("@octokit/auth");
// or:
// import {
//   createAppAuth,
//   createOAuthAppAuth,
//   createTokenAuth,
//   createActionAuth
// } from "@octokit/auth";
const auth = createAppAuth({
  appId: 12345,
  privateKey: "...",
});

Each function exported by @octokit/auth returns an async auth function.

The auth function resolves with an authentication object. If multiple authentication types are supported, a type parameter can be passed.

const { token } = await auth({ type: "app" });

Additionally, auth.hook() can be used to directly hook into @octokit/request. If multiple authentication types are supported, the right authentication type will be applied automatically based on the request URL.

const requestWithAuth = request.defaults({
  request: {
    hook: auth.hook,
  },
});

const { data: authorizations } = await requestWithAuth("GET /authorizations");

Official Strategies

Comparison

Module Strategy Options Auth Options Authentication objects

@octokit/auth-token

token
-
{
  type: "token",
  token: "secret123",
  tokenType, "oauth" // or "installation"
}

@octokit/auth-app

{
  id*,
  privateKey*,
  installationId,
  cache,
  request
}
{
  type*, // "app" or "installation"
  installationId,
  repositoryIds,
  permissions,
  refresh
}
{
  type: "app",
  token: "abc.def.1234",
  appId: 123,
  expiresAt: "2019-06-11T22:22:34Z"
}
{
  type: "token",
  tokenType: "installation",
  token: "v1.secret123",
  installationId: 1234,
  expiresAt: "2019-06-11T22:22:34Z",
  repositoryIds: [12345],
  permissions: {
    single_file: 'write'
  },
  singleFileName: '.github/myapp.yml'
}

@octokit/auth-oauth-app

{
  clientId*,
  clientSecret*,
  code,
  redirectUrl,
  state,
  request
}
{
  type*, // "oauth-app" or "token"
  url
}
{
  type: "oauth-app",
  clientId: "abc123",
  clientSecret: "abc123secret",
  headers: {},
  query: {
    clientId: "abc123",
    clientSecret: "abc123secret"
  }
}
{
  type: "token",
  tokenType: "oauth",
  token: "123secret",
  scopes: []
}

@octokit/auth-action

-
-
{
  type: "token",
  tokenType: "installation",
  token: "v1.123secret"
}

Token authentication

Example

const auth = createTokenAuth("1234567890abcdef1234567890abcdef12345678");
const { token, tokenType } = await auth();

See @octokit/auth-token for more details.

GitHub App or installation authentication

Example

const auth = createAppAuth({
  appId: 1,
  privateKey: "-----BEGIN RSA PRIVATE KEY-----\n...",
});

const appAuthentication = await auth({ type: "auth" });
const installationAuthentication = await auth({
  type: "installation",
  installationId: 123,
});

See @octokit/auth-app for more details.

OAuth app and OAuth access token authentication

Example

const auth = createOAuthAppAuth({
  clientId: "1234567890abcdef1234",
  clientSecret: "1234567890abcdef1234567890abcdef12345678",
  code: "random123", // code from OAuth web flow, see https://git.io/fhd1D
});

const appAuthentication = await auth({
  type: "oauth-app",
  url: "/orgs/{org}/repos",
});
const tokenAuthentication = await auth({ type: "token" });

See @octokit/auth-oauth-app for more details.

GitHub Action authentication

Example

// expects process.env.GITHUB_ACTION and process.env.GITHUB_TOKEN to be set
const auth = createActionAuth();
const { token } = await auth();

See @octokit/auth-action for more details.

Community Strategies

.netrc authentication

Similar to token authentication, but reads the token from your ~/.netrc file

Example

// expects a personal access token to be set as `login` in the `~/.netrc` file for `api.github.com`
const { createNetrcAuth } = require("octokit-netrc-auth");
const auth = createNetrcAuth();
const { token } = await auth();

See octokit-auth-netrc for more details.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].