# get-github-auth-token

> Retrieves the running user's GitHub authentication token. 🪙

Latest version **0.2.0** (published 2026-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-github-auth-token
pnpm add get-github-auth-token
yarn add get-github-auth-token
bun add get-github-auth-token
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2026-08-21 |
| First published | 2024-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Author | Josh Goldberg ✨ |
| Maintainers | joshuakgoldberg |

## Links

- npm: https://www.npmjs.com/package/get-github-auth-token
- Repository: https://github.com/JoshuaKGoldberg/get-github-auth-token
- Homepage: https://github.com/JoshuaKGoldberg/get-github-auth-token#readme
- Issues: https://github.com/JoshuaKGoldberg/get-github-auth-token/issues
- npm.io page: https://npm.io/package/get-github-auth-token

## Recent versions

- 0.2.0 (latest) — 2026-08-21
- 0.1.2 — 2025-03-31
- 0.1.1 — 2025-01-15
- 0.1.0 — 2024-05-26

## README

<h1 align="center">get-github-auth-token</h1>

<p align="center">
	Retrieves the running user's GitHub authentication token.
	🪙
</p>

<p align="center">
	<!-- prettier-ignore-start -->
	<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
	<a href="#contributors" target="_blank"><img alt="👪 All Contributors: 2" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-2-21bb42.svg" /></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
	<!-- prettier-ignore-end -->
	<a href="https://github.com/JoshuaKGoldberg/get-github-auth-token/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
	<a href="https://codecov.io/gh/JoshuaKGoldberg/get-github-auth-token" target="_blank"><img alt="🧪 Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/get-github-auth-token?label=%F0%9F%A7%AA%20coverage" /></a>
	<a href="https://github.com/JoshuaKGoldberg/get-github-auth-token/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg" /></a>
	<a href="http://npmjs.com/package/get-github-auth-token" target="_blank"><img alt="📦 npm version" src="https://img.shields.io/npm/v/get-github-auth-token?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
	<img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
</p>

## Usage

```shell
npm i get-github-auth-token
```

```ts
import { getGitHubAuthToken } from "get-github-auth-token";

const auth = await getGitHubAuthToken("Hello, world! 💖");

if (auth.succeeded) {
	console.log("Token:", auth.token);
} else {
	console.error("Oh no:", auth.error);
}
```

`getGitHubAuthToken` attempts to find a GitHub auth token from the following places, in order:

1. `process.env.GH_TOKEN`
2. `process.env.GITHUB_TOKEN`
3. Executing `gh auth token` as a child process

> 💡 Using this to create a new [Octokit](https://octokit.github.io/rest.js) instance?
> See [JoshuaKGoldberg/octokit-from-auth](https://github.com/JoshuaKGoldberg/octokit-from-auth).

## Development

See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
Thanks! 🪙

## Contributors

<!-- spellchecker: disable -->
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tbody>
    <tr>
      <td align="center"><a href="http://www.joshuakgoldberg.com/"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg ✨"/><br /><sub><b>Josh Goldberg ✨</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/get-github-auth-token/commits?author=JoshuaKGoldberg" title="Code">💻</a> <a href="#content-JoshuaKGoldberg" title="Content">🖋</a> <a href="https://github.com/JoshuaKGoldberg/get-github-auth-token/commits?author=JoshuaKGoldberg" title="Documentation">📖</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="#projectManagement-JoshuaKGoldberg" title="Project Management">📆</a> <a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a> <a href="https://github.com/JoshuaKGoldberg/get-github-auth-token/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a></td>
      <td align="center"><a href="https://uncenter.dev"><img src="https://avatars.githubusercontent.com/u/47499684?v=4?s=100" width="100px;" alt="uncenter"/><br /><sub><b>uncenter</b></sub></a><br /><a href="#ideas-uncenter" title="Ideas, Planning, & Feedback">🤔</a></td>
    </tr>
  </tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- spellchecker: enable -->

> 💝 This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo framework](https://create.bingo).

---
_Source: https://npm.io/package/get-github-auth-token · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
