@@ -50,8 +50,9 @@ object each time you want to use it. The example below shows how to create a
5050service for the Google Drive API.
5151
5252 function getDriveService() {
53- // Create a new service with the given name. The name will be used when persisting the
54- // authorized token, so ensure it is unique within the scope of the property store.
53+ // Create a new service with the given name. The name will be used when
54+ // persisting the authorized token, so ensure it is unique within the
55+ // scope of the property store.
5556 return OAuth2.createService('drive')
5657
5758 // Set the endpoint URLs, which are the same for all Google services.
@@ -65,8 +66,8 @@ service for the Google Drive API.
6566 // Set the project key of the script using this library.
6667 .setProjectKey('...')
6768
68- // Set the name of the callback function in the script referenced above that should be
69- // invoked to complete the OAuth flow.
69+ // Set the name of the callback function in the script referenced
70+ // above that should be invoked to complete the OAuth flow.
7071 .setCallbackFunction('authCallback')
7172
7273 // Set the property store where authorized tokens should be persisted.
@@ -75,9 +76,17 @@ service for the Google Drive API.
7576 // Set the scopes to request (space-separated for Google services).
7677 .setScope('https://www.googleapis.com/auth/drive')
7778
78- // Set any additional OAuth2 parameters, in this case requesting offline access and
79- // forcing the approval prompt to be shown.
79+ // Below are Google-specific OAuth2 parameters.
80+
81+ // Sets the login hint, which will prevent the account chooser screen
82+ // from being shown to users logged in with multiple accounts.
83+ .setParam('login_hint', Session.getActiveUser.getEmail())
84+
85+ // Requests offline access.
8086 .setParam('access_type', 'offline')
87+
88+ // Forces the approval prompt every time. This is useful for testing,
89+ // but not desirable in a production application.
8190 .setParam('approval_prompt', 'force');
8291 }
8392
0 commit comments