1
1
/**
2
- * Saleforce's Auth flow https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm
2
+ * Saleforce Auth flow
3
+ * @see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm
3
4
*/
4
5
5
6
var CLIENT_ID = '...' ;
@@ -12,8 +13,8 @@ function run() {
12
13
var service = getService ( ) ;
13
14
if ( service . hasAccess ( ) ) {
14
15
// GET requests require access_token parameter
15
-
16
- var response = UrlFetchApp . fetch ( service . getToken ( ) . instance_url + '/services/data/v24.0/chatter/users/me' , {
16
+ var url = service . getToken ( ) . instance_url + '/services/data/v24.0/chatter/users/me' ;
17
+ var response = UrlFetchApp . fetch ( url , {
17
18
headers : {
18
19
Authorization : 'Bearer ' + service . getAccessToken ( )
19
20
}
@@ -22,8 +23,7 @@ function run() {
22
23
Logger . log ( JSON . stringify ( result , null , ' ' ) ) ;
23
24
} else {
24
25
var authorizationUrl = service . getAuthorizationUrl ( ) ;
25
- Logger . log ( 'Open the following URL and re-run the script: %s' ,
26
- authorizationUrl ) ;
26
+ Logger . log ( 'Open the following URL and re-run the script: ' + authorizationUrl ) ;
27
27
}
28
28
}
29
29
@@ -65,14 +65,6 @@ function authCallback(request) {
65
65
if ( authorized ) {
66
66
return HtmlService . createHtmlOutput ( 'Success!' ) ;
67
67
} else {
68
- return HtmlService . createHtmlOutput ( 'Denied' ) ;
68
+ return HtmlService . createHtmlOutput ( 'Denied. ' ) ;
69
69
}
70
70
}
71
-
72
- /**
73
- * Logs the redict URI to register in the Saleforce Apps Page.
74
- */
75
- function logRedirectUri ( ) {
76
- var service = getService ( ) ;
77
- Logger . log ( service . getRedirectUri ( ) ) ;
78
- }
0 commit comments