Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49082

How to get the user data from ionic.io social authentication

$
0
0

@kendam wrote:

I needed to get the user details from ionic.io 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(){

$ionicLoading.show({
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');
$ionicLoading.hide()
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
$ionicLoading.hide()
                    //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);

};

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49082

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>