Previous: , Up: OAuth2 on GitHub   [Index]


1.3 Authentication using OctoKit

"Extendable client for GitHub’s REST & GraphQL APIs"

@octokit/core is a minimalistic library to utilize GitHub’s REST API and GraphQL API which you can extend with plugins as needed.

If you don’t need the Plugin API then using @octokit/request or @octokit/graphql directly is a good alternative.

In the browser, load @octokit/core directly from cdn.skypack.dev:

<script type="module">import { Octokit } from "https://cdn.skypack.dev/@octokit/core";</script>

Using Node.js, install with npm then require or import the library.

npm install @octokit/core
const { Octokit } = require("@octokit/core");
// or
import { Octokit } from "@octokit/core";

Here is a minimal example of its use:

// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: `personal-access-token123` });

const response = await octokit.request("GET /orgs/{org}/repos", {
  org: "octokit",
  type: "private",
});

See