Created
October 19, 2017 20:20
-
-
Save Danil0v3s/f4b9f6434b11b2d1a0e18b0a282fb53e to your computer and use it in GitHub Desktop.
This file contains 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
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