netrc auth plugin for Octokit
npm install octokit-auth-netrc[![Codecov][coverage-badge]][coverage-link]
[![Node CI Workflow Status][github-actions-ci-badge]][github-actions-ci-link]
[![OpenSSF Scorecard][ossfScorecard-badge]][ossfScorecard-link]
![SLSA Level 2][slsa-badge]
* Usage
* Installation
* Defining your token
* Example
* Import
* Authenticate
* API
* createNetrcAuth
* Contributing
* Dependencies
* Verification
[![MIT license][license-badge]][license-link]
[![npm][npm-badge]][npm-link]
[![Try octokit-auth-netrc on RunKit][runkit-badge]][runkit-link]
![node][node-badge]
``sh`
$ npm install octokit-auth-netrc --save-prod
Add a personal access token
to your ~/.netrc file
`
machine api.github.com
login
machine github.acme-inc.com
login
`
#### Import
`javascript`
import {createNetrcAuth} from './lib/index.cjs';
#### Authenticate
`javascript
/defaults to api.github.com/
const auth = createNetrcAuth();
/For use with GHES, override the default domain/
const enterpriseAuth = createNetrcAuth({ domain: 'github.acme-inc.com' });
(async () => {
await auth();
await enterpriseAuth();
})();
`
#### createNetrcAuth
Returns an auth() function
after reading your token from the ~/.netrc file. Throws an error with codeENONETRCTOKEN when an entry for api.github.com is not found in the~/.netrc file.
[![PRs Welcome][PRs-badge]][PRs-link]
[![Conventional Commits][commit-convention-badge]][commit-convention-link]
[![Commitizen friendly][commitizen-badge]][commitizen-link]
[![semantic-release][semantic-release-badge]][semantic-release-link]
[![Renovate][renovate-badge]][renovate-link]
`sh`
$ nvm install
$ npm install
`sh``
$ NODE_OPTIONS=--no-experimental-fetch npm test
[PRs-link]: http://makeapullrequest.com
[PRs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[commit-convention-link]: https://conventionalcommits.org
[commit-convention-badge]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
[commitizen-link]: http://commitizen.github.io/cz-cli/
[commitizen-badge]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[semantic-release-link]: https://github.com/semantic-release/semantic-release
[semantic-release-badge]: https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release
[renovate-link]: https://renovatebot.com
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=renovatebot
[coverage-link]: https://codecov.io/github/travi/octokit-auth-netrc
[coverage-badge]: https://img.shields.io/codecov/c/github/travi/octokit-auth-netrc?logo=codecov
[license-link]: LICENSE
[license-badge]: https://img.shields.io/github/license/travi/octokit-auth-netrc.svg?logo=opensourceinitiative
[npm-link]: https://www.npmjs.com/package/octokit-auth-netrc
[npm-badge]: https://img.shields.io/npm/v/octokit-auth-netrc?logo=npm
[runkit-link]: https://npm.runkit.com/octokit-auth-netrc
[runkit-badge]: https://badge.runkitcdn.com/octokit-auth-netrc.svg
[github-actions-ci-link]: https://github.com/travi/octokit-auth-netrc/actions?query=workflow%3A%22Node.js+CI%22+branch%3Amaster
[github-actions-ci-badge]: https://img.shields.io/github/actions/workflow/status/travi/octokit-auth-netrc/node-ci.yml.svg?branch=master&logo=github
[node-badge]: https://img.shields.io/node/v/octokit-auth-netrc?logo=node.js
[ossfScorecard-link]: https://securityscorecards.dev/viewer/?uri=github.com/travi/octokit-auth-netrc
[ossfScorecard-badge]: https://api.securityscorecards.dev/projects/github.com/travi/octokit-auth-netrc/badge
[slsa-badge]: https://slsa.dev/images/gh-badge-level2.svg