Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions samples/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const fs = require('fs');
const path = require('path');
const http = require('http');
const url = require('url');
const opn = require('open');
const destroyer = require('server-destroy');
const open = require('open');

const {google} = require('googleapis');
const people = google.people('v1');
Expand Down Expand Up @@ -63,9 +62,10 @@ async function authenticate(scopes) {
const qs = new url.URL(req.url, 'http://localhost:3000')
.searchParams;
res.end('Authentication successful! Please return to the console.');
server.destroy();
server.closeAllConnections();
server.close();
const {tokens} = await oauth2Client.getToken(qs.get('code'));
oauth2Client.credentials = tokens; // eslint-disable-line require-atomic-updates
oauth2Client.credentials = tokens;
resolve(oauth2Client);
}
} catch (e) {
Expand All @@ -74,9 +74,9 @@ async function authenticate(scopes) {
})
.listen(3000, () => {
// open the browser to the authorize url to start the workflow
opn(authorizeUrl, {wait: false}).then(cp => cp.unref());
open(authorizeUrl, {wait: false}).then(cp => cp.unref());
});
destroyer(server);

});
}

Expand Down
5 changes: 2 additions & 3 deletions samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"googleapis": "^171.1.0",
"googleapis-common": "^8.0.2-rc.0",
"nconf": "^0.13.0",
"open": "^8.0.0",
"server-destroy": "^1.0.1"
"open": "^8.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand All @@ -31,4 +30,4 @@
"proxyquire": "^2.1.3",
"typescript": "^4.6.4"
}
}
}
Loading