# githubauthquerystring

> Authorise GitHub API requests by appending the environments auth credentials to your request's query string.

Latest version **4.0.0** (published 2020-03-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install githubauthquerystring
pnpm add githubauthquerystring
yarn add githubauthquerystring
bun add githubauthquerystring
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2020-03-26 |
| First published | 2018-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 27 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | 2018+ Benjamin Lupton |
| Maintainers | balupton, bevryme |
| Keywords | api, auth, browser, export-default, github, module, querystring, typed, types, typescript |

## Links

- npm: https://www.npmjs.com/package/githubauthquerystring
- Repository: https://github.com/bevry/githubauthquerystring
- Issues: https://github.com/bevry/githubauthquerystring/issues
- Funding: https://bevry.me/fund
- npm.io page: https://npm.io/package/githubauthquerystring

## Dependencies (1)

- [simplytyped](https://npm.io/package/simplytyped.md) ^3.2.3

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2020-03-26
- 4.0.0-next.1585263623.4ac93fc04f86b47d62732dff79bbc996c8578681 (next) — 2020-03-26
- 4.0.0-next.1585263604.26ff4873284e129ff5fb4cebd0e77fa724a520a6 — 2020-03-26
- 4.0.0-next.1585262913.8d626171c108a63018da090bce64020145f31212 — 2020-03-26
- 3.0.1-next.1576647590.1e0b8a6b75715e201ab828f6ed1026202e312b9c — 2019-12-18
- 3.0.1-next.1576646917.f0a8d44b64a1e6e1a2ab7ff0130e0c08b2503817 — 2019-12-18
- 3.0.1 — 2019-12-18
- 3.0.1-next.1576646437.f7b8c4b0f2683eb1faf0f374b230970d860652fa — 2019-12-18
- 3.0.0 — 2019-12-18
- 3.0.0-next.1576646146.a6f7540f2b8543bab771cabfbaf5aba15e184d86 — 2019-12-18
- 2.3.0 — 2019-12-09
- 2.3.0-next.1575882892.f0cf3d78fa7c1fa21eb33d5a0c2c00edbe0f0bf3 — 2019-12-09
- 2.2.0 — 2019-12-01
- 2.2.0-next.1575176233.e241cce993614efa16e44b29c903e1910a2dbd4c — 2019-12-01
- 2.1.0 — 2019-11-30
- … 14 more at https://npm.io/package/githubauthquerystring/versions

## README

<!-- TITLE/ -->

<h1>githubauthquerystring</h1>

<!-- /TITLE -->


<!-- BADGES/ -->

<span class="badge-travisci"><a href="http://travis-ci.com/bevry/githubauthquerystring" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/com/bevry/githubauthquerystring/master.svg" alt="Travis CI Build Status" /></a></span>
<span class="badge-npmversion"><a href="https://npmjs.org/package/githubauthquerystring" title="View this project on NPM"><img src="https://img.shields.io/npm/v/githubauthquerystring.svg" alt="NPM version" /></a></span>
<span class="badge-npmdownloads"><a href="https://npmjs.org/package/githubauthquerystring" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/githubauthquerystring.svg" alt="NPM downloads" /></a></span>
<span class="badge-daviddm"><a href="https://david-dm.org/bevry/githubauthquerystring" title="View the status of this project's dependencies on DavidDM"><img src="https://img.shields.io/david/bevry/githubauthquerystring.svg" alt="Dependency Status" /></a></span>
<span class="badge-daviddmdev"><a href="https://david-dm.org/bevry/githubauthquerystring#info=devDependencies" title="View the status of this project's development dependencies on DavidDM"><img src="https://img.shields.io/david/dev/bevry/githubauthquerystring.svg" alt="Dev Dependency Status" /></a></span>
<br class="badge-separator" />
<span class="badge-githubsponsors"><a href="https://github.com/sponsors/balupton" title="Donate to this project using GitHub Sponsors"><img src="https://img.shields.io/badge/github-donate-yellow.svg" alt="GitHub Sponsors donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>

<!-- /BADGES -->


<!-- DESCRIPTION/ -->

Authorise GitHub API requests by appending the environments auth credentials to your request's query string.

<!-- /DESCRIPTION -->


## Usage

[Complete API Documentation.](http://master.githubauthquerystring.bevry.surge.sh/docs/globals.html)

### Fetch

Using environment variables:

```javascript
import githubAuthQueryString from 'githubauthquerystring'
const githubURL = `https://api.github.com/user?${githubAuthQueryString}`
```

Using manual `GITHUB_ACCESS_TOKEN`:

```javascript
import { fetch } from 'githubauthquerystring'
const githubAuthQueryString = fetch({
    GITHUB_ACCESS_TOKEN: 'value',
})
const githubURL = `https://api.github.com/user?${githubAuthQueryString}`
```

Using manual `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`:

```javascript
import { fetch } from 'githubauthquerystring'
const githubAuthQueryString = fetch({
    GITHUB_CLIENT_ID: 'value',
    GITHUB_CLIENT_SECRET: 'value',
})
const githubURL = `https://api.github.com/user?${githubAuthQueryString}`
```

If the values did not exist or were not in a valid combination, then an empty string will be returned.

### Redaction

When error reporting, you should redact the error message to prevent credentials from leaking in log files:

```javascript
import { fetch as fetchGithubAuthQueryString, redact } from 'githubauthquerystring'
import 'fetch' from 'cross-fetch'

// fetch the url
const githubAuthQueryString = fetchGithubAuthQueryString({
    GITHUB_CLIENT_ID: 'value',
    GITHUB_CLIENT_SECRET: 'value'
})
const githubURL = `https://api.github.com/user?${githubAuthQueryString}`

// fetch the response
(async function () {
    try {
        const resp = await fetch(githubURL)
        const data = await resp.json()
    }
    catch (err) {
        // redact the error before logging it
        console.error(redact(err.message))
    }
})()
```

### Renaming

If you would like to rename the methods to something else, you can do it like so:

```javascript
// using named imports
import ghQueryString, {
    fetch as fetchGithubAuthQueryString,
    redact as redactGithubAuthQueryString,
} from 'githubauthquerystring'

// using destructuring
const {
    default: ghQueryString,
    fetch: fetchGithubAuthQueryString,
    redact: redactGithubAuthQueryString,
} = require('githubauthquerystring')
```

<!-- INSTALL/ -->

<h2>Install</h2>

<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a>
<ul>
<li>Install: <code>npm install --save githubauthquerystring</code></li>
<li>Import: <code>import pkg from ('githubauthquerystring')</code></li>
<li>Require: <code>const pkg = require('githubauthquerystring').default</code></li>
</ul>

<a href="https://www.pika.dev/cdn" title="100% Native ES Modules CDN"><h3>pika</h3></a>

``` html
<script type="module">
    import pkg from '//cdn.pika.dev/githubauthquerystring/^4.0.0'
</script>
```

<a href="https://unpkg.com" title="unpkg is a fast, global content delivery network for everything on npm"><h3>unpkg</h3></a>

``` html
<script type="module">
    import pkg from '//unpkg.com/githubauthquerystring@^4.0.0'
</script>
```

<a href="https://jspm.io" title="Native ES Modules CDN"><h3>jspm</h3></a>

``` html
<script type="module">
    import pkg from '//dev.jspm.io/githubauthquerystring@4.0.0'
</script>
```

<h3><a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>

<p>This package is published with the following editions:</p>

<ul><li><code>githubauthquerystring/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
<li><code>githubauthquerystring/edition-browsers/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for web browsers with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
<li><code>githubauthquerystring</code> aliases <code>githubauthquerystring/edition-es2018/index.js</code></li>
<li><code>githubauthquerystring/edition-es2018/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#9th_Edition_-_ECMAScript_2018" title="ECMAScript ES2018">ES2018</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li></ul>

<!-- /INSTALL -->


<!-- HISTORY/ -->

<h2>History</h2>

<a href="https://github.com/bevry/githubauthquerystring/blob/master/HISTORY.md#files">Discover the release history by heading on over to the <code>HISTORY.md</code> file.</a>

<!-- /HISTORY -->


<!-- CONTRIBUTE/ -->

<h2>Contribute</h2>

<a href="https://github.com/bevry/githubauthquerystring/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

<!-- /CONTRIBUTE -->


<!-- BACKERS/ -->

<h2>Backers</h2>

<h3>Maintainers</h3>

These amazing people are maintaining this project:

<ul><li>Benjamin Lupton</li></ul>

<h3>Sponsors</h3>

No sponsors yet! Will you be the first?

<span class="badge-githubsponsors"><a href="https://github.com/sponsors/balupton" title="Donate to this project using GitHub Sponsors"><img src="https://img.shields.io/badge/github-donate-yellow.svg" alt="GitHub Sponsors donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>

<h3>Contributors</h3>

These amazing people have contributed code to this project:

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/githubauthquerystring/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/githubauthquerystring">view contributions</a></li>
<li><a href="http://github.com/apps/dependabot-preview">dependabot-preview[bot]</a> — <a href="https://github.com/bevry/githubauthquerystring/commits?author=dependabot-preview[bot]" title="View the GitHub contributions of dependabot-preview[bot] on repository bevry/githubauthquerystring">view contributions</a></li></ul>

<a href="https://github.com/bevry/githubauthquerystring/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

<!-- /BACKERS -->


<!-- LICENSE/ -->

<h2>License</h2>

Unless stated otherwise all works are:

<ul><li>Copyright &copy; 2018+ Benjamin Lupton</li></ul>

and licensed under:

<ul><li><a href="http://spdx.org/licenses/MIT.html">MIT License</a></li></ul>

<!-- /LICENSE -->

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