1
1
/*
2
- * Facebook oAuth 2.0 guide API requests
2
+ * Facebook OAuth 2.0 guides:
3
3
* https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
4
4
* https://developers.facebook.com/apps/
5
5
*/
@@ -15,8 +15,7 @@ function run(e) {
15
15
var service = getService ( ) ;
16
16
var html = '' ;
17
17
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' ;
20
19
var response = UrlFetchApp . fetch ( url , {
21
20
headers : {
22
21
'Authorization' : 'Bearer ' + service . getAccessToken ( )
@@ -27,7 +26,7 @@ function run(e) {
27
26
} else {
28
27
var authorizationUrl = service . getAuthorizationUrl ( ) ;
29
28
Logger . log ( 'Open the following URL and re-run the script: %s' ,
30
- authorizationUrl ) ;
29
+ authorizationUrl ) ;
31
30
}
32
31
}
33
32
@@ -44,20 +43,20 @@ function reset() {
44
43
*/
45
44
function getService ( ) {
46
45
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' )
50
49
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 )
54
53
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' )
58
57
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 ( ) ) ;
61
60
}
62
61
63
62
/**
@@ -71,4 +70,4 @@ function authCallback(request) {
71
70
} else {
72
71
return HtmlService . createHtmlOutput ( 'Denied' ) ;
73
72
}
74
- }
73
+ }
0 commit comments