google-authorize
Advanced tools
Comparing version 1.0.3 to 1.0.4
30
index.js
@@ -14,7 +14,10 @@ const fs = require('fs'); | ||
* Default constructor | ||
* @param {array} scopes An array representing the scopes | ||
* @param {Array} scopes An array representing the scopes | ||
* to authorize for the oauth2Client. Example ['spreadsheets'] would | ||
* correlate with ..googleapis.com/auth/spreadsheets. | ||
* @param {String} credentialsPath Where your Google credentials.json lives. | ||
* Defaults to 'credentials.json' which is relative to your execution | ||
* context. | ||
*/ | ||
constructor(scopes) { | ||
constructor(scopes, credentialsPath) { | ||
// If modifying these scopes, delete your previously saved credentials | ||
@@ -35,2 +38,3 @@ // at ~/.credentials/credentials.json | ||
this.TOKEN_PATH = this.TOKEN_DIR + 'googleapis.json'; | ||
this.credentialsPath = credentialsPath || 'credentials.json'; | ||
} | ||
@@ -47,13 +51,13 @@ /** | ||
// Load client secrets from a local file. | ||
fs.readFile('credentials.json', | ||
function processClientSecrets(err, content) { | ||
if (err) { | ||
console.error('Error loading credentials.json file: ' + err); | ||
reject(err); | ||
return; | ||
} | ||
// Authorize a client with the loaded credentials, then call the | ||
// Google Sheets API. | ||
resolve(this._authorize(JSON.parse(content))); | ||
}.bind(this)); | ||
fs.readFile(this.credentialsPath, | ||
function processClientSecrets(err, content) { | ||
if (err) { | ||
console.error('Error loading credentials.json file: ' + err); | ||
reject(err); | ||
return; | ||
} | ||
// Authorize a client with the loaded credentials, then call the | ||
// Google Sheets API. | ||
resolve(this._authorize(JSON.parse(content))); | ||
}.bind(this)); | ||
}); | ||
@@ -60,0 +64,0 @@ } |
{ | ||
"name": "google-authorize", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Get an OAuth2 client with authorized token to be used with Google APIs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7714
141