Skip to content

Commit

Permalink
chore: upgrade to the latest google-auth-library and fix the build (#953
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JustinBeckwith committed Jan 24, 2018
1 parent 8669d9a commit eb9e1d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
26 changes: 12 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"license": "Apache-2.0",
"dependencies": {
"async": "2.6.0",
"google-auth-library": "^1.0.0",
"google-auth-library": "^1.1.0",
"qs": "^6.5.1",
"string-template": "1.0.0",
"uuid": "^3.1.0"
Expand Down
17 changes: 9 additions & 8 deletions test/test.auth.ts
Expand Up @@ -195,26 +195,27 @@ describe('OAuth2 client', () => {
});

it('should make request if access token not expired', async () => {
const scope = nock('https://accounts.google.com')
.post('/o/oauth2/token')
const scope = nock('https://www.googleapis.com')
.post('/oauth2/v4/token')
.times(2)
.reply(200, {access_token: 'abc123', expires_in: 10000});
let oauth2client =
new googleapis.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
let now = (new Date()).getTime();
let tenSecondsFromNow = now + 10000;
let tenMinutesFromNow = now + 1000 * 60 * 10;
oauth2client.credentials = {
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenSecondsFromNow
expiry_date: tenMinutesFromNow
};

nock(Utils.baseUrl).get('/drive/v2/files/wat').reply(200);
await pify(localDrive.files.get)({fileId: 'wat', auth: oauth2client});
console.log(`Creds: ${JSON.stringify(oauth2client.credentials)}`);
assert.equal(JSON.stringify(oauth2client.credentials), JSON.stringify({
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenSecondsFromNow,
expiry_date: tenMinutesFromNow,
token_type: 'Bearer'
}));

Expand All @@ -224,19 +225,19 @@ describe('OAuth2 client', () => {
oauth2client =
new googleapis.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
now = (new Date()).getTime();
tenSecondsFromNow = now + 10000;
tenMinutesFromNow = now + 1000 * 60 * 10;
oauth2client.credentials = {
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenSecondsFromNow
expiry_date: tenMinutesFromNow
};

nock(Utils.baseUrl).get('/drive/v2/files/wat').reply(200);
await pify(remoteDrive.files.get)({fileId: 'wat', auth: oauth2client});
assert.equal(JSON.stringify(oauth2client.credentials), JSON.stringify({
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenSecondsFromNow,
expiry_date: tenMinutesFromNow,
token_type: 'Bearer'
}));

Expand Down

0 comments on commit eb9e1d9

Please sign in to comment.