How to get the user data from social authentication

I needed to get the user details from social Auth provider
The following are the implementations, this works fine as I am able to login the users with it, the only problem is the user data is empty, how do I get things like the First Name, Last Name, email and the profile pics .

$scope.facebookLogIn = function(){

template:‘Login in…’

var authProvider = ‘facebook’;
var authSettings = { ‘remember’: true };

var authSuccess = function(user) {
// user was authenticated, you can get the authenticated user
// with Ionic.User.current();
console.log(‘Facebook login was successful’);
var currentUser = Ionic.User.current();
console.log(‘The current facebook user is’+ currentUser);
localStorageService.set(‘loggedinuser’, currentUser );
var alertPopup = $ionicPopup.alert({
title: ‘success’,
template: JSON.stringify(user)


var authFailure = function(errors) {

// check the error and provide an appropriate message
// for your application
                    //error callback
                     var alertPopup = $ionicPopup.alert({
    title: 'We could not sign you in!',
    template: JSON.stringify(errors)


Ionic.Auth.login(authProvider, authSettings)
.then(authSuccess, authFailure);


1 Like

I have the same problem

Same here. Looking at the user registration, both Facebook and Twitter users are present, however I want to also ask them for their mobile number as I do in the regular signup through adding the details.custom.

Any help on either getting the info from Twitter/Facebook and also asking for the custom data field would be most helpful.

I have a similar problem.
In first place, i think that the user data is not totally empty. You can get the google_id or facebook_id;
If you have in your controller something like:
Ionic.Auth.login(provider, {‘remember’: true})
.then(function (authSuccess, authFailure) {
var user = Ionic.User.current();
if (user.isAuthenticated()) {
Then, if your provider is google, you have your user id in user.details.google_id, and if your provider is facebook: user.details.facebook_id
Remember that in your Facebook App, doesnt have to choose “Android App”, but Web app.

In this case, to get the profile pictures is easy:
.service(‘AuthService’, function($http){
var service = this;
service.getAvatar = function (tipo,iduser) {
if(tipo == ‘google’)
return $http.get('’+iduser+’?fields=image&key=’+API_KEY).then(function(response){
else if(tipo == ‘facebook’) return ‘’+iduser+’/picture?type=square’;
else return ‘img/avatar.png’;
I hope it help.
But my actual problem is that i can’t get the username. Anybody knows how to get the username and why the ionic io auth always show name=null?

@ldpalazon, I’ll give that a try. Thanks for the tip!

I for some reason always get a “Not Logged In : You are not logged in” anytime I try to use the Facebook Login (Twitter works just fine). Did you ever see that before?

As a return tip to you…using your same logic…I know it defeats the purpose of “ease”, but if you have the Facebook ID and an API Access Token, you can use:

which returns

{"name": "First Lastname","id": "user_id"}

@IndyJones72, two notes:

  • I had the same error: It was a misconfiguration of my Facebook App because I added a Android platform, and It doesnt work with Ionic. Your Facebook App has to be only for Web. And of course you need the tokens correctly configured in your ionic panel, and your ionic app code has to be correctly syncronized with the app you are working on. When I had that error I started from the begining and I created the Facebook App again, and now it works.

  • About your solution, to get the username in that way I need an access token that I dont have, because the Ionic Auth doesnt return that value.

Finally I have found a github issue about this problems:

In two or three weeks there will be a solution! (I hope)