Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed920c0

Browse files
author
Eric Koleda
authored
Merge pull request googleworkspace#23 from gsuitedevs/unhandledpromise
Log an error when there is an issue exchanging the authorization code
2 parents d9c4dcb + 9a70563 commit ed920c0

File tree

12 files changed

+18
-18
lines changed

12 files changed

+18
-18
lines changed

adminSDK/directory/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fs.readFile('credentials.json', (err, content) => {
4141
*/
4242
function authorize(credentials, callback) {
4343
const {client_secret, client_id, redirect_uris} = credentials.installed;
44-
const oauth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
44+
const oauth2Client = new google.auth.OAuth2(
45+
client_id, client_secret, redirect_uris[0]);
4546

4647
// Check if we have previously stored a token.
4748
fs.readFile(TOKEN_PATH, (err, token) => {
@@ -72,8 +73,7 @@ function getNewToken(oauth2Client, callback) {
7273
rl.question('Enter the code from that page here: ', (code) => {
7374
rl.close();
7475
oauth2Client.getToken(code, (err, token) => {
75-
if (err) return console.error('Error while trying to retrieve access token', err);
76-
76+
if (err) return console.error('Error retrieving access token', err);
7777
oauth2Client.credentials = token;
7878
storeToken(token);
7979
callback(oauth2Client);

adminSDK/reports/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fs.readFile('credentials.json', (err, content) => {
4141
*/
4242
function authorize(credentials, callback) {
4343
const {client_secret, client_id, redirect_uris} = credentials.installed;
44-
const oauth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
44+
const oauth2Client = new google.auth.OAuth2(
45+
client_id, client_secret, redirect_uris[0]);
4546

4647
// Check if we have previously stored a token.
4748
fs.readFile(TOKEN_PATH, (err, token) => {
@@ -72,8 +73,7 @@ function getNewToken(oauth2Client, callback) {
7273
rl.question('Enter the code from that page here: ', (code) => {
7374
rl.close();
7475
oauth2Client.getToken(code, (err, token) => {
75-
if (err) return console.error('Error while trying to retrieve access token', err);
76-
76+
if (err) return console.error('Error retrieving access token', err);
7777
oauth2Client.credentials = token;
7878
storeToken(token);
7979
callback(oauth2Client);

adminSDK/reseller/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fs.readFile('credentials.json', (err, content) => {
4141
*/
4242
function authorize(credentials, callback) {
4343
const {client_secret, client_id, redirect_uris} = credentials.installed;
44-
const oauth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
44+
const oauth2Client = new google.auth.OAuth2(
45+
client_id, client_secret, redirect_uris[0]);
4546

4647
// Check if we have previously stored a token.
4748
fs.readFile(TOKEN_PATH, (err, token) => {
@@ -72,8 +73,7 @@ function getNewToken(oauth2Client, callback) {
7273
rl.question('Enter the code from that page here: ', (code) => {
7374
rl.close();
7475
oauth2Client.getToken(code, (err, token) => {
75-
if (err) return console.error('Error while trying to retrieve access token', err);
76-
76+
if (err) return console.error('Error retrieving access token', err);
7777
oauth2Client.credentials = token;
7878
storeToken(token);
7979
callback(oauth2Client);

apps-script/quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getAccessToken(oAuth2Client, callback) {
6868
rl.question('Enter the code from that page here: ', (code) => {
6969
rl.close();
7070
oAuth2Client.getToken(code, (err, token) => {
71-
if (err) return callback(err);
71+
if (err) return console.error('Error retrieving access token', err);
7272
oAuth2Client.setCredentials(token);
7373
// Store the token to disk for later program executions
7474
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

calendar/quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getAccessToken(oAuth2Client, callback) {
6868
rl.question('Enter the code from that page here: ', (code) => {
6969
rl.close();
7070
oAuth2Client.getToken(code, (err, token) => {
71-
if (err) return callback(err);
71+
if (err) return console.error('Error retrieving access token', err);
7272
oAuth2Client.setCredentials(token);
7373
// Store the token to disk for later program executions
7474
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

classroom/quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getNewToken(oAuth2Client, callback) {
6868
rl.question('Enter the code from that page here: ', (code) => {
6969
rl.close();
7070
oAuth2Client.getToken(code, (err, token) => {
71-
if (err) return callback(err);
71+
if (err) return console.error('Error retrieving access token', err);
7272
oAuth2Client.setCredentials(token);
7373
// Store the token to disk for later program executions
7474
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

drive/activity/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function getNewToken(oAuth2Client, callback) {
7070
rl.question('Enter the code from that page here: ', (code) => {
7171
rl.close();
7272
oAuth2Client.getToken(code, (err, token) => {
73-
if (err) return callback(err);
73+
if (err) return console.error('Error retrieving access token', err);
7474
oAuth2Client.setCredentials(token);
7575
// Store the token to disk for later program executions
7676
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

drive/quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getAccessToken(oAuth2Client, callback) {
6868
rl.question('Enter the code from that page here: ', (code) => {
6969
rl.close();
7070
oAuth2Client.getToken(code, (err, token) => {
71-
if (err) return callback(err);
71+
if (err) return console.error('Error retrieving access token', err);
7272
oAuth2Client.setCredentials(token);
7373
// Store the token to disk for later program executions
7474
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

gmail/quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getNewToken(oAuth2Client, callback) {
6868
rl.question('Enter the code from that page here: ', (code) => {
6969
rl.close();
7070
oAuth2Client.getToken(code, (err, token) => {
71-
if (err) return callback(err);
71+
if (err) return console.error('Error retrieving access token', err);
7272
oAuth2Client.setCredentials(token);
7373
// Store the token to disk for later program executions
7474
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

sheets/quickstart/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getNewToken(oAuth2Client, callback) {
6868
rl.question('Enter the code from that page here: ', (code) => {
6969
rl.close();
7070
oAuth2Client.getToken(code, (err, token) => {
71-
if (err) return callback(err);
71+
if (err) return console.error('Error while trying to retrieve access token', err);
7272
oAuth2Client.setCredentials(token);
7373
// Store the token to disk for later program executions
7474
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {

0 commit comments

Comments
 (0)