Skip to content

Commit

Permalink
chore: remove example keyfiles (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Mar 15, 2018
1 parent e900d4c commit 8d98867
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,7 +3,6 @@ node_modules
doc/
npm-debug.log
coverage
.secrets.json
# Empty API
apis/iam/v1alpha1.js
.nyc_output
Expand All @@ -13,3 +12,4 @@ apis/iam/v1alpha1.js
.vscode
**/*.d.ts
**/credentials.json
samples/*.keys.json
8 changes: 7 additions & 1 deletion samples/jwt.js
Expand Up @@ -14,6 +14,8 @@
'use strict';

const {google} = require('googleapis');
const fs = require('fs');
const path = require('path');

/**
* The JWT authorization is ideal for performing server-to-server
Expand All @@ -25,7 +27,11 @@ const {google} = require('googleapis');
* See the defaultauth.js sample for an alternate way of fetching compute credentials.
*/

const keys = require('./jwt.keys.json');
let keys = {};
const keyPath = path.join(__dirname, 'jwt.keys.json');
if (fs.existsSync(keyPath)) {
keys = require(keyPath);
}

// Create a new JWT client using the key file downloaded from the Google Developer Console
const jwtClient = new google.auth.JWT({
Expand Down
12 changes: 0 additions & 12 deletions samples/jwt.keys.json

This file was deleted.

13 changes: 0 additions & 13 deletions samples/oauth2.keys.json

This file was deleted.

16 changes: 7 additions & 9 deletions samples/sampleclient.js
Expand Up @@ -19,28 +19,26 @@
*/

const {google} = require('googleapis');
const OAuth2Client = google.auth.OAuth2;
const http = require('http');
const url = require('url');
const querystring = require('querystring');
const opn = require('opn');
const nconf = require('nconf');
const path = require('path');
const destroyer = require('server-destroy');
const fs = require('fs');
const path = require('path');

nconf.argv().env()
.file(path.join(__dirname, 'oauth2.keys.json'));
let keys = nconf.get('web');
if (typeof keys === 'string') {
keys = JSON.parse(keys);
const keyPath = path.join(__dirname, 'oauth2.keys.json');
let keys = { redirect_uris: [''] };
if (fs.existsSync(keyPath)) {
keys = require(keyPath).web;
}

class SampleClient {
constructor (options) {
this._options = options || { scopes: [] };

// create an oAuth client to authorize the API call
this.oAuth2Client = new OAuth2Client(
this.oAuth2Client = new google.auth.OAuth2(
keys.client_id,
keys.client_secret,
keys.redirect_uris[0]
Expand Down

0 comments on commit 8d98867

Please sign in to comment.