Skip to content

Instantly share code, notes, and snippets.

@guilhermedecampo
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermedecampo/506a1ab7abbba36399c0 to your computer and use it in GitHub Desktop.
Save guilhermedecampo/506a1ab7abbba36399c0 to your computer and use it in GitHub Desktop.
Accounts.onCreateUser(function(options, user) {
// We're enforcing at least an empty profile object to avoid needing to check
// for its existence later.
if (user.services && user.services.facebook) {
var
accessToken = user.services.facebook.accessToken,
result,
profile,
config
;
result = Meteor.http.get("https://graph.facebook.com/me", {
params: {
access_token: accessToken
}
});
if (result.error)
throw result.error;
profile = result.data;
user.profile = profile;
} else {
user.profile = options.profile ? options.profile : {};
}
return user;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment