From 71064afd342c230eadf2841a87c53d28dcaad77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Denis?= Date: Fri, 29 Nov 2019 16:14:47 +0100 Subject: [PATCH 1/2] Update example for Google OAuth2 offline access --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d5afca8a..dd36e73e 100644 --- a/README.md +++ b/README.md @@ -124,14 +124,13 @@ function getDriveService() { // Sets the login hint, which will prevent the account chooser screen // from being shown to users logged in with multiple accounts. + // Prefer Session.getEffectiveUser().getEmail() if used in add-ons. .setParam('login_hint', Session.getActiveUser().getEmail()) // Requests offline access. .setParam('access_type', 'offline') - - // Forces the approval prompt every time. This is useful for testing, - // but not desirable in a production application. - .setParam('approval_prompt', 'force'); + // This param is required to ensure a refresh token is always returned. + .setParam('prompt', 'consent'); } ``` From 3530650a8b80c93ff2eb62a6a445d6beb3f7377b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Denis?= Date: Wed, 4 Dec 2019 10:59:46 +0100 Subject: [PATCH 2/2] Code review updates - Use Session.getEffectiveUser() instead of Session.getActiveUser() - Restore blank lines - Wording update --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dd36e73e..0d030457 100644 --- a/README.md +++ b/README.md @@ -124,12 +124,13 @@ function getDriveService() { // Sets the login hint, which will prevent the account chooser screen // from being shown to users logged in with multiple accounts. - // Prefer Session.getEffectiveUser().getEmail() if used in add-ons. - .setParam('login_hint', Session.getActiveUser().getEmail()) + .setParam('login_hint', Session.getEffectiveUser().getEmail()) // Requests offline access. .setParam('access_type', 'offline') - // This param is required to ensure a refresh token is always returned. + + // Consent prompt is required to ensure a refresh token is always + // returned when requesting offline access. .setParam('prompt', 'consent'); } ```