# google-authorize

> Get an OAuth2 client with authorized token to be used with Google APIs.

Latest version **1.0.4** (published 2019-02-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install google-authorize
pnpm add google-authorize
yarn add google-authorize
bun add google-authorize
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-02-08 |
| First published | 2017-01-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | kmedley |
| Maintainers | kurtlocker |
| Keywords | googleapis, google, authorize, auth, google-auth |

## Links

- npm: https://www.npmjs.com/package/google-authorize
- Repository: https://github.com/kurtlocker/google-authorize
- Homepage: https://github.com/kurtlocker/google-authorize#readme
- Issues: https://github.com/kurtlocker/google-authorize/issues
- npm.io page: https://npm.io/package/google-authorize

## Dependencies (1)

- [google-auth-library](https://npm.io/package/google-auth-library.md) ^0.10.0

## 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
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2019-02-08
- 1.0.3 — 2019-01-26
- 1.0.2 — 2018-11-06
- 1.0.1 — 2017-01-04
- 1.0.0 — 2017-01-03

## README

# Google Authorize

Get an OAuth2 client with an authorized token to be used with Google APIs.


All I want for Christmas is to be able to easily start working with the Google APIs. There is a nice [Node quickstart](https://developers.google.com/sheets/api/quickstart/nodejs) that Google provides for this. This module is a wrapper of that code but instead of executing a callback function that passes a resultant OAuth2 client, it returns a Promise that is _thenable_ which resolves the OAuth2 client.

Here's how to use it:

Visit [Node quickstart](https://developers.google.com/sheets/api/quickstart/nodejs) and complete Step 1 to get your client_secret.json.

```bash
npm i google-authorize --save
```

```javascript
const GoogleAuthorize = require('google-authorize');

// Use an array of scopes that correlate to to googleapi scopes
// i.e. ['spreadsheets'] -> https://www.googleapis.com/auth/spreadsheets
const googleAuth = new GoogleAuthorize(['spreadsheets']);

// Authorize and then make a request to the sheets API
googleAuth.authorize().then(listMajors);

function listMajors(auth) {
  var sheets = require('googleapis').sheets('v4');
  sheets.spreadsheets.values.get({
    auth: auth,
    spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
    range: 'Class Data!A2:E',
  }, function(err, response) {
    if (err) {
      console.log('The API returned an error: ' + err);
      return;
    }
    var rows = response.values;
    if (rows.length == 0) {
      console.log('No data found.');
    } else {
      console.log('Name, Major:');
      for (var i = 0; i < rows.length; i++) {
        var row = rows[i];
        // Print columns A and E, which correspond to indices 0 and 4.
        console.log('%s, %s', row[0], row[4]);
      }
    }
  });
}

## Change Log
Nov 6 2018 - Fixed undefined callback on fs.writeFile

```

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