google-oauth2-client-promisify
Redesign the Node.js code in document on google developers 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.
var oauth2Client = ;var google = ;var gmail = google; /*** 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 ;