Fix Google auth

This commit is contained in:
Jim LAURIE 2019-07-12 19:46:09 +02:00
parent 3cfeb645c1
commit 2b9e03f3de

View File

@ -159,17 +159,37 @@ const getProfile = async (provider, query, callback) => {
break; break;
} }
case 'google': { case 'google': {
const google = new Purest({ const config = {
provider: 'google' "google": {
}); "https://www.googleapis.com": {
"__domain": {
"auth": {
"auth": {"bearer": "[0]"}
}
},
"{endpoint}": {
"__path": {
"alias": "__default"
}
},
"oauth/[version]/{endpoint}": {
"__path": {
"alias": "oauth",
"version": "v3"
}
}
}
}
}
var google = new Purest({provider: 'google', config})
google.query('plus').get('people/me').auth(access_token).request((err, res, body) => { google.query('oauth').get('tokeninfo').qs({access_token}).request((err, res, body) => {
if (err) { if (err) {
callback(err); callback(err);
} else { } else {
callback(null, { callback(null, {
username: body.emails[0].value.split("@")[0], username: body.email.split("@")[0],
email: body.emails[0].value email: body.email
}); });
} }
}); });