# google-oauth2-client-promisify

> Redesign the code that create OAuth2 client into promise chain and then wrap it as module, return promise with credentials which is thenable.

Latest version **1.0.12** (published 2017-01-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install google-oauth2-client-promisify
pnpm add google-oauth2-client-promisify
yarn add google-oauth2-client-promisify
bun add google-oauth2-client-promisify
```

## 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.12 |
| Published | 2017-01-07 |
| First published | 2017-01-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Carr |
| Maintainers | carr |

## Links

- npm: https://www.npmjs.com/package/google-oauth2-client-promisify
- Repository: https://github.com/Carr1005/google-oauth2-client-promisify
- Homepage: https://github.com/Carr1005/google-oauth2-client-promisify#readme
- Issues: https://github.com/Carr1005/google-oauth2-client-promisify/issues
- npm.io page: https://npm.io/package/google-oauth2-client-promisify

## Dependencies (1)

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

## Recent versions

- 1.0.12 (latest) — 2017-01-07
- 1.0.11 — 2017-01-03
- 1.0.10 — 2017-01-02
- 1.0.8 — 2017-01-02
- 1.0.7 — 2017-01-02
- 1.0.6 — 2017-01-02
- 1.0.4 — 2017-01-02
- 1.0.0 — 2017-01-01

## README

# google-oauth2-client-promisify
Redesign the Node.js code in [document on google developers](https://developers.google.com/gmail/api/quickstart/nodejs) that describe the process for creating OAuth2 client and getting credentials. Wrap it as a tiny module and hope to be a good starting point for anyone gonna handle Google APIs in futher with promise-style.

## Installation
```
npm install google-oauth2-client-promisify
```

## Example - calling the Gmail API

### Note:
- Make sure that client secrets (json file) was downloaded and moved into your working directory.
- ```npm install googleapis --save``` that allow you to deal with google api.

```js
var oauth2Client = require('google-oauth2-client-promisify');
var google = require('googleapis');
var gmail = google.gmail('v1');

/**
* CLIENT_SECRET_FILE: Path of your client secret file.
* TOKEN_FILE: Just give a name you like for the json file which store token.
* SCOPES: Decide what kind of permission would be authorized. 
* More details in -> https://developers.google.com/gmail/api/auth/scopes
*/

var CLIENT_SECRET_FILE = 'client_secret_blablabla.json';
var TOKEN_FILE = 'gmail-nodejs-collect-mails.json';
var SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];

oauth2Client.createOauth2Client(CLIENT_SECRET_FILE,SCOPES,TOKEN_FILE)
	.then( auth => {
		gmail.users.messages.list({
				auth: auth
				,userId: 'me'
				,maxResults: '500'
			}, (err, response) => {
				if (err) 
					throw err;
				else
					console.log(response.messages);
		});
	})
	.catch( err => {
		console.log(err);
	});

```

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