Created
May 20, 2015 23:54
-
-
Save michaelfward/d2d93faa4f80fbd7ebfb to your computer and use it in GitHub Desktop.
Function to generate facebook access token. Requires the https library, an object named keys with app ID and client secret, and facebook-node-sdk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateAccessToken(callback){ | |
var requestUrl = 'https://graph.facebook.com/oauth/access_token?client_id='+keys.facebook.appID+'&client_secret='+keys.facebook.secret+'&grant_type=client_credentials'; | |
https.get(requestUrl, function(response){ | |
response.on('data', function(data){ | |
var token = data.toString('utf-8').split("access_token="); | |
FacebookClient.setAccessToken(token[1]); | |
callback(); | |
}); | |
}).on('error', function(error){ | |
console.log(error); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment