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 */
4544function 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+ }
0 commit comments