diff --git a/samples/oauth2.js b/samples/oauth2.js index 00a51c3381..d581214e88 100644 --- a/samples/oauth2.js +++ b/samples/oauth2.js @@ -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'); @@ -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) { @@ -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); + }); } diff --git a/samples/package.json b/samples/package.json index 4ba5dd640d..7b301df055 100644 --- a/samples/package.json +++ b/samples/package.json @@ -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", @@ -31,4 +30,4 @@ "proxyquire": "^2.1.3", "typescript": "^4.6.4" } -} \ No newline at end of file +}