This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -3,8 +3,7 @@
> GitHub API token authentication for browsers and Node.js
[![@latest](https://img.shields.io/npm/v/@octokit/auth-token.svg)](https://www.npmjs.com/package/@octokit/auth-token)
[![Build Status](https://travis-ci.com/octokit/auth-token.js.svg?branch=master)](https://travis-ci.com/octokit/auth-token.js)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/auth-token.js.svg)](https://greenkeeper.io/)
[![Build Status](https://github.com/octokit/auth-token.js/workflows/Test/badge.svg)](https://github.com/octokit/auth-token.js/actions?query=workflow%3ATest)
`@octokit/auth-token` is the simplest of [GitHubs authentication strategies](https://github.com/octokit/auth.js).
@@ -12,6 +11,20 @@ It is useful if you want to support multiple authentication strategies, as it
<!-- toc -->
- [Usage](#usage)
- [`createTokenAuth(token) options`](#createtokenauthtoken-options)
- [`auth()`](#auth)
- [Authentication object](#authentication-object)
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
- [Find more information](#find-more-information)
- [Find out what scopes are enabled for oauth tokens](#find-out-what-scopes-are-enabled-for-oauth-tokens)
- [Find out if token is a personal access token or if it belongs to an OAuth app](#find-out-if-token-is-a-personal-access-token-or-if-it-belongs-to-an-oauth-app)
- [Find out what permissions are enabled for a repository](#find-out-what-permissions-are-enabled-for-a-repository)
- [Use token for git operations](#use-token-for-git-operations)
- [License](#license)
<!-- tocstop -->
## Usage
<table>
@@ -149,8 +162,8 @@ Or it can be passed as option to [`request()`](https://github.com/octokit/reques
```js
const requestWithAuth = request.defaults({
request: {
hook: auth.hook
}
hook: auth.hook,
},
});
const { data: authorizations } = await requestWithAuth("GET /authorizations");
@@ -173,7 +186,7 @@ const auth = createTokenAuth(TOKEN);
const authentication = await auth();
const response = await request("HEAD /", {
headers: authentication.headers
headers: authentication.headers,
});
const scopes = response.headers["x-oauth-scopes"].split(/,\s+/);
@@ -195,7 +208,7 @@ const auth = createTokenAuth(TOKEN);
const authentication = await auth();
const response = await request("HEAD /", {
headers: authentication.headers
headers: authentication.headers,
});
const clientId = response.headers["x-oauth-client-id"];