@@ -119,7 +119,7 @@ <h2>Redirect URI</h2>
119119 * Logs the redirect URI to register.
120120 */
121121function logRedirectUri() {
122- var service = getService ();
122+ var service = getService_ ();
123123 Logger.log(service.getRedirectUri());
124124}
125125</ code > </ pre >
@@ -131,7 +131,7 @@ <h3>1. Create the OAuth2 service</h3>
131131information is not persisted to any data store, so you'll need to create this
132132object each time you want to use it. The example below shows how to create a
133133service for the Google Drive API.</ p >
134- < pre class ="prettyprint source lang-js "> < code > function getDriveService () {
134+ < pre class ="prettyprint source lang-js "> < code > function getDriveService_ () {
135135 // Create a new service with the given name. The name will be used when
136136 // persisting the authorized token, so ensure it is unique within the
137137 // scope of the property store.
@@ -174,7 +174,7 @@ <h3>2. Direct the user to the authorization URL</h3>
174174you'll need to present the authorization URL as a link for the user to click.
175175The URL is generated by the service, using the function < code > getAuthorizationUrl()</ code > .</ p >
176176< pre class ="prettyprint source lang-js "> < code > function showSidebar() {
177- var driveService = getDriveService ();
177+ var driveService = getDriveService_ ();
178178 if (!driveService.hasAccess()) {
179179 var authorizationUrl = driveService.getAuthorizationUrl();
180180 var template = HtmlService.createTemplate(
@@ -194,7 +194,7 @@ <h3>3. Handle the callback</h3>
194194request object to the service's < code > handleCallback</ code > function, and show a message
195195to the user.</ p >
196196< pre class ="prettyprint source lang-js "> < code > function authCallback(request) {
197- var driveService = getDriveService ();
197+ var driveService = getDriveService_ ();
198198 var isAuthorized = driveService.handleCallback(request);
199199 if (isAuthorized) {
200200 return HtmlService.createHtmlOutput('Success! You can close this tab.');
@@ -212,7 +212,7 @@ <h3>4. Get the access token</h3>
212212requests to the API. The access token can be passed along with a < code > UrlFetchApp</ code >
213213request in the "Authorization" header.</ p >
214214< pre class ="prettyprint source lang-js "> < code > function makeRequest() {
215- var driveService = getDriveService ();
215+ var driveService = getDriveService_ ();
216216 var response = UrlFetchApp.fetch('https://www.googleapis.com/drive/v2/files?maxResults=10', {
217217 headers: {
218218 Authorization: 'Bearer ' + driveService.getAccessToken()
@@ -225,7 +225,7 @@ <h3>Logout</h3>
225225< p > To logout the user or disconnect the service, perhaps so the user can select a
226226different account, use the < code > reset()</ code > method:</ p >
227227< pre class ="prettyprint source lang-js "> < code > function logout() {
228- var service = getDriveService ()
228+ var service = getDriveService_ ()
229229 service.reset();
230230}
231231</ code > </ pre >
@@ -326,7 +326,7 @@ <h4>Storing token-related data</h4>
326326in the callback URL. In the following code the account ID is extracted from the
327327request parameters and saved saved into storage.</ p >
328328< pre class ="prettyprint source lang-js "> < code > function authCallback(request) {
329- var service = getService ();
329+ var service = getService_ ();
330330 var authorized = service.handleCallback(request);
331331 if (authorized) {
332332 // Gets the authorized account ID from the scope string. Assumes the
@@ -368,7 +368,7 @@ <h4>Passing additional parameters to the callback function</h4>
368368token, which is a standard mechanism for this purpose. To do so, pass an
369369optional hash of parameter names and values to the < code > getAuthorizationUrl()</ code >
370370method:</ p >
371- < pre class ="prettyprint source lang-js "> < code > var authorizationUrl = getService ().getAuthorizationUrl({
371+ < pre class ="prettyprint source lang-js "> < code > var authorizationUrl = getService_ ().getAuthorizationUrl({
372372 // Pass the additional parameter "lang" with the value "fr".
373373 lang: 'fr'
374374});
@@ -419,17 +419,17 @@ <h3>How can I connect to multiple OAuth services?</h3>
419419multiple services merely ensure they have different service names. Often this
420420means selecting a service name that matches the API the user will authorize:</ p >
421421< pre class ="prettyprint source lang-js "> < code > function run() {
422- var gitHubService = getGitHubService ();
423- var mediumService = getMediumService ();
422+ var gitHubService = getGitHubService_ ();
423+ var mediumService = getMediumService_ ();
424424 // ...
425425}
426426
427- function getGitHubService () {
427+ function getGitHubService_ () {
428428 return OAuth2.createService('GitHub')
429429 // GitHub settings ...
430430}
431431
432- function getMediumService () {
432+ function getMediumService_ () {
433433 return OAuth2.createService('Medium')
434434 // Medium settings ...
435435}
@@ -439,12 +439,12 @@ <h3>How can I connect to multiple OAuth services?</h3>
439439those cases you'll need to devise your own method for creating unique service
440440names:</ p >
441441< pre class ="prettyprint source lang-js "> < code > function run() {
442- var copyFromService = getGitHubService ('from');
443- var copyToService = getGitHubService ('to');
442+ var copyFromService = getGitHubService_ ('from');
443+ var copyToService = getGitHubService_ ('to');
444444 // ...
445445}
446446
447- function getGitHubService (label) {
447+ function getGitHubService_ (label) {
448448 return OAuth2.createService('GitHub_' + label)
449449 // GitHub settings ...
450450}
0 commit comments