Skip to content

Instantly share code, notes, and snippets.

@Danil0v3s
Created October 19, 2017 20:20
Show Gist options
  • Save Danil0v3s/f4b9f6434b11b2d1a0e18b0a282fb53e to your computer and use it in GitHub Desktop.
Save Danil0v3s/f4b9f6434b11b2d1a0e18b0a282fb53e to your computer and use it in GitHub Desktop.
exports.facebook = async (access_token) => {
const fields = 'id, name, email, picture';
const url = 'https://graph.facebook.com/me';
const params = { access_token, fields };
const response = await axios.get(url, { params });
const { id, name, email, picture } = response.data;
return {
service: 'facebook',
picture: picture.data.url,
id,
name,
email,
};
};
exports.google = async (access_token) => {
const url = 'https://www.googleapis.com/oauth2/v3/userinfo';
const params = { access_token };
const response = await axios.get(url, { params });
const { sub, name, email, picture } = response.data;
return {
service: 'google',
picture,
id: sub,
name,
email,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment