I am creating a webapp in angularJs, and using satellizer for authentication. I am able to use to authenticate using google, but I couldn't figure out how to get email id of authenticated user somewhere in my UI code. I couldn't found any function also to get email id in documentation.
All I had to do was, hit googleapis using the access_token satelizer save in your browser's local memory, which returns user info, Following is the service for your reference:
angular.module('MyApp')
.factory('Google', ['$resource', '$auth', Google]);
function Google($resource, $auth) {
return $resource("https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" + $auth.getToken(), {}, {})
}
You can just do following to get email id of logged in user:
var googleResponse = Google.get({}, function () {
var email = googleResponse.email;
});