Skip to content

Commit fc85bd5

Browse files
author
Eric Koleda
committed
Formatting changes to Facebook and Meetup samples. Changed Facebook sample to show authorized user's profile.
1 parent 36b30cf commit fc85bd5

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

samples/Facebook.gs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Facebook oAuth 2.0 guide API requests
2+
* Facebook OAuth 2.0 guides:
33
* https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
44
* https://developers.facebook.com/apps/
55
*/
@@ -15,8 +15,7 @@ function run(e) {
1515
var service = getService();
1616
var html = '';
1717
if (service.hasAccess()) {
18-
// Takes info about the id 100002297950397
19-
var url = 'https://graph.facebook.com/v2.6/100002297950397';
18+
var url = 'https://graph.facebook.com/v2.6/me';
2019
var response = UrlFetchApp.fetch(url, {
2120
headers: {
2221
'Authorization': 'Bearer ' + service.getAccessToken()
@@ -27,7 +26,7 @@ function run(e) {
2726
} else {
2827
var authorizationUrl = service.getAuthorizationUrl();
2928
Logger.log('Open the following URL and re-run the script: %s',
30-
authorizationUrl);
29+
authorizationUrl);
3130
}
3231
}
3332

@@ -44,20 +43,20 @@ function reset() {
4443
*/
4544
function getService() {
4645
return OAuth2.createService('Facebook')
47-
// Set the endpoint URLs.
48-
.setAuthorizationBaseUrl('https://www.facebook.com/dialog/oauth')
49-
.setTokenUrl('https://graph.facebook.com/v2.3/oauth/access_token')
46+
// Set the endpoint URLs.
47+
.setAuthorizationBaseUrl('https://www.facebook.com/dialog/oauth')
48+
.setTokenUrl('https://graph.facebook.com/v2.6/oauth/access_token')
5049

51-
// Set the client ID and secret.
52-
.setClientId(CLIENT_ID)
53-
.setClientSecret(CLIENT_SECRET)
50+
// Set the client ID and secret.
51+
.setClientId(CLIENT_ID)
52+
.setClientSecret(CLIENT_SECRET)
5453

55-
// Set the name of the callback function that should be invoked to complete
56-
// the OAuth flow.
57-
.setCallbackFunction('authCallback')
54+
// Set the name of the callback function that should be invoked to complete
55+
// the OAuth flow.
56+
.setCallbackFunction('authCallback')
5857

59-
// Set the property store where authorized tokens should be persisted.
60-
.setPropertyStore(PropertiesService.getUserProperties());
58+
// Set the property store where authorized tokens should be persisted.
59+
.setPropertyStore(PropertiesService.getUserProperties());
6160
}
6261

6362
/**
@@ -71,4 +70,4 @@ function authCallback(request) {
7170
} else {
7271
return HtmlService.createHtmlOutput('Denied');
7372
}
74-
}
73+
}

samples/Meetup.gs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Extend your community - Meetup. Meetup API
2+
* Meetup API Guides:
33
* http://www.meetup.com/meetup_api/
44
* http://www.meetup.com/meetup_api/auth/#oauth2
55
*/
@@ -25,7 +25,7 @@ function run() {
2525
} else {
2626
var authorizationUrl = service.getAuthorizationUrl();
2727
Logger.log('Open the following URL and re-run the script: %s',
28-
authorizationUrl);
28+
authorizationUrl);
2929
}
3030
}
3131

@@ -42,20 +42,20 @@ function reset() {
4242
*/
4343
function getService() {
4444
return OAuth2.createService('Meetup')
45-
// Set the endpoint URLs.
46-
.setAuthorizationBaseUrl('https://secure.meetup.com/oauth2/authorize')
47-
.setTokenUrl('https://secure.meetup.com/oauth2/access')
45+
// Set the endpoint URLs.
46+
.setAuthorizationBaseUrl('https://secure.meetup.com/oauth2/authorize')
47+
.setTokenUrl('https://secure.meetup.com/oauth2/access')
4848

49-
// Set the client ID and secret.
50-
.setClientId(CLIENT_ID)
51-
.setClientSecret(CLIENT_SECRET)
49+
// Set the client ID and secret.
50+
.setClientId(CLIENT_ID)
51+
.setClientSecret(CLIENT_SECRET)
5252

53-
// Set the name of the callback function that should be invoked to complete
54-
// the OAuth flow.
55-
.setCallbackFunction('authCallback')
53+
// Set the name of the callback function that should be invoked to complete
54+
// the OAuth flow.
55+
.setCallbackFunction('authCallback')
5656

57-
// Set the property store where authorized tokens should be persisted.
58-
.setPropertyStore(PropertiesService.getUserProperties());
57+
// Set the property store where authorized tokens should be persisted.
58+
.setPropertyStore(PropertiesService.getUserProperties());
5959
}
6060

6161
/**
@@ -69,4 +69,4 @@ function authCallback(request) {
6969
} else {
7070
return HtmlService.createHtmlOutput('Denied');
7171
}
72-
}
72+
}

0 commit comments

Comments
 (0)