Skip to content
This repository has been archived by the owner. It is now read-only.

Social Login not collecting user info #20

Closed
sagivf opened this issue Jul 10, 2016 · 90 comments
Closed

Social Login not collecting user info #20

sagivf opened this issue Jul 10, 2016 · 90 comments

Comments

@sagivf
Copy link

@sagivf sagivf commented Jul 10, 2016

Most auth systems collect the social providers user data (name, email at times, etc...).
At least for google it doesn't seem to do so.

@imhoffd
Copy link
Contributor

@imhoffd imhoffd commented Jul 10, 2016

@sagivf -- @devnetics is actually working on this right now. None of the current social providers are collecting additional information. This was a known limitation that we are now addressing. I'll keep this open to inform you when you can expect this functionality.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Jul 13, 2016

@dwieeb - Ok so even though this was for Google, we'll at the very least hopefully have this information for Google, Facebook and Twitter?

@imhoffd imhoffd changed the title Google Login not collecting user info Social Login not collecting user info Jul 13, 2016
@imhoffd
Copy link
Contributor

@imhoffd imhoffd commented Jul 13, 2016

@IndyJones72 Yes! I changed the title so it is more fitting.

@imhoffd imhoffd added this to the @ionic/cloud beta release milestone Jul 15, 2016
@sagivf
Copy link
Author

@sagivf sagivf commented Jul 17, 2016

@dwieeb I've been wondering - will the platform do some sort of unification of the same person with different social logins or will each one create a new user in the system?

Not sure myself which is better, I'm guessing they could be unified based on the email. Probably best if it were configurable.

@imhoffd
Copy link
Contributor

@imhoffd imhoffd commented Jul 17, 2016

@sagivf Unification of users is actually pretty complex. Even once you're sure they're the same person (via email, for example), merging data and avoiding data destruction is a complicated process. Not all social networks give us email addresses and most don't give enough general data to piece things together.

But honestly, I don't see logins being merged. If a user shares an email address in two social networks and logs in to your app with one network then the other, they would expect to have a completely new account, not their data from the other. Best to keep them as separate accounts.

That being said, data analysis on users can be done while maintaining the two separate accounts. This is something we're interested in looking at later. But, obviously there's much to do before that.

@sagivf
Copy link
Author

@sagivf sagivf commented Jul 17, 2016

@dwieeb I agree with all of what you say.
Take into consideration that there are use cases were you want a user to sign in one way. then validate his email, then add social logins for all sorts of info from the social provider.

This is defiantly not a common use case for apps and not necessary to do with authentication, but it's good to keep in mind.

@imhoffd
Copy link
Contributor

@imhoffd imhoffd commented Jul 17, 2016

@sagivf Ah, yeah. Not a use case we'd tackle with our authentication. Devs are free to add those additional hookups themselves and then save such information in users' custom data. I would say it's not in our scope to add support for that, something which could be done with plugins such as cordova-plugin-facebook4 or libraries.

@jaspervanveghel
Copy link

@jaspervanveghel jaspervanveghel commented Aug 5, 2016

Are there any updates to report on the approximate completion date of this yet? We would like to integrate this into our app, which we'd like to release at the end of this month.

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 5, 2016

@jaspervanveghel This will be released by the end of next week. I'll update here when it's live.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 5, 2016

@devnetics - great news. We are also looking to release at the end of the month and this will be great to have

@ghost
Copy link

@ghost ghost commented Aug 12, 2016

@devnetics did you have any news :) we also have a release but next month and give full facebook login with complete user data will be great!

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 12, 2016

Hey guys, we have the PR ready to go on the backend to support Oauth provider user data. We didn't want to turn on a fairly complex new feature Friday afternoon, so we're hitting the on switch Monday morning. I'll post here when it's live.

We are giving you access to the basic user details (such as username, email (when available), full_name, and profile_picture), and then also recorded a raw_data object that gives you access to any of the other data that that particular provider happens to return on the Users/Self endpoint (for example, Github returns things like location, created_at, hireable, followers, etc.).

Note: We are not providing access to the provider tokens, that is still under discussion.

@cfjedimaster
Copy link

@cfjedimaster cfjedimaster commented Aug 13, 2016

Can I ask why you don't want to (possibly) provide the token?

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 13, 2016

@devnetics - Great news, and I completely understand about throwing the switch on a Friday afternoon. Really looking forward to this on Monday.

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 13, 2016

@devnetics Thanks for working on this.

I have recently implemented something similar for a web app and was wondering regarding keeping the user data up to date - meaning what happens if a user changes his photo / email / name etc... It's not critical for most apps, but could be in some cases.

Is there any implementation of this?
If not perhaps suppling the token will at least give the developers the option.

A few words of advice:

  1. Make sure that after a user logs back in you override the data with the new results.
  2. Obviously you can update the user data in a background Job, but what I do is only update once an hours for active users (ones using the api).
  3. Twitter - you need a OAuth for any data. You can use a general app token but there is a rate limit. The good news is that twitter users tokens don't expire.
  4. Facebook - you can get most data with a simple GET request with an access_token. Some fields are available with a simple app access_token, but some (like email) you need the users access_token and that has an expiry (which can be extended with a refresh token).
  5. Facebook Image - that can easily be fetched dynamically by the userId.

Let me know if you I can help in any way and thanks again :)

(Perhaps I should open a new ticket for this)

@ghost
Copy link

@ghost ghost commented Aug 15, 2016

Hi @devnetics, does the PR it's ready to update or it will take a little more to be available?

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 16, 2016

@ArkangelB We soft launched it yesterday. The new docs and cloud client are also on their way, which will give you local access to the provider data (on log in with the cloud client), and the docs will demonstrate how to use it. If you're feeling antsy and want it right now, you can use the latest version of the cloud client github.com/driftyco/ionic-cloud, but I would recommend waiting for our next publish to npm for any production level applications.

@sagivf Thanks! We already have it updating user's. Any data that is changed gets overridden, anything that did not change (say for example the new set of data that comes in doesn't have email, but the old set does have email) stays the same. Currently this happens on user login.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 17, 2016

@devnetics - just a quick shoutout...this is working pretty darn well.

I share a few of our fellow posters in that having the token would be useful so we could obtain the email address of the user, however...and I'm reaching here...is it possible to send an email to Facebook somehow incorporating the user's FB id? If so, maybe we don't need it and not have to worry about the token and added layers of difficulty that FB may add.

Just wanted to say thank you for getting this adjusted and out there. We should be almost set to release at the end of the month with this.

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 17, 2016

Thanks @devnetics, great to see this coming along.
But do you pull to update the user details (like changing his name or photo)? Or does the user have to re login?

@swapnilagarwwal
Copy link

@swapnilagarwwal swapnilagarwwal commented Aug 17, 2016

@devnetics please suggest when will it be available for public npm ?
I am on ionic version 2.0.0
Currently I am using cordova-plugin-facebook4, it is not clean.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 17, 2016

Ok am I reading the code incorrectly, or shouldn't the new social login info be available in $ionicUser.social after a successful login?

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 17, 2016

@IndyJones72 I may be wrong here but I think this is only for Ionic2, although this feature could probably easily be back ported as it's mostly server side.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 17, 2016

@sagivf - oh man I feel dumb then. I had thought ionic cloud was for both platforms as I did the whole migration from web platform to ionic.cloud and everything seemed to work so that's why I had asked.

I do see the "data" in my network debug feed and see everything coming back from the social service. However I can't use that data for some reason in the promise...all I get is the uuid. So I'm sure I'm doing something wrong here.

How difficult is it to convert your ionic 1 to ionic 2? I know there's documentation out there so not looking for details. Just curious as to the effort involved.

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 17, 2016

Actually you maybe right @IndyJones72, I guess your using the compiled results of typescript source...

I re-wrote my app since I had a lot of business changes due anyway.

My advice would be:

  1. Ionic2 and angular2 are very different then there predecesores so conversion would probably be very tricky.

  2. Writing the code Is usually much simpler then then getting your UX flow and business logic in place. So re-writes are not that big of a deal unless you have a very sensitive, monologic business with little documentation and code which nobody knows what it does.

  3. Ionic2 is much faster to write. They've locked down a lot of good concepts and the TypeScript intelisence is very helpful.

  4. If your using Ionic-cloud that takes away a lot of complications like login/push/etc...

Good luck either way :)

@swapnilagarwwal
Copy link

@swapnilagarwwal swapnilagarwwal commented Aug 17, 2016

@sagivf I believe data for social authentication will be available for ionic 1.3.
The documentation http://docs.ionic.io/docs/user-usage is available for ionic 1.3.

@imhoffd
Copy link
Contributor

@imhoffd imhoffd commented Aug 17, 2016

Here's how this works. The Cloud Client initiates a series of HTTP redirects through our servers and the social network. At this time we store the social data, such as name, email, and profile picture on the user. The user is returned to the Cloud Client and that data will be available under $ionicUser.social, as @IndyJones72 mentioned. Our new documentation will have more details and you can wait for it if you're struggling.

@sagivf Ionic Cloud Client doesn't rely on the Ionic Framework. You can use it in Ionic 2 and Ionic 1 apps. The integration of the client into those frameworks may differ, but our new documentation will feature both.

@sagivf @IndyJones72 Perhaps it's best to wait for another npm release. I'm planning on one today or tomorrow.

@sagivf That's very good advice. 👍 I agree with all of it.

@agarwalswapnil Those are our current docs, which won't mention anything about this new feature.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 17, 2016

@dwieeb - Thanks so much for the reply and the clarification. If you have another npm scheduled today, I probably will wait for that...install it since it seems the compiled version I have is missing the social part of that new user object. Please let us know when it's out there so I can give it a whirl. Thanks!

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 22, 2016

Full notes to all for what to expect this week:

  1. Facebook should be getting you an email address now. There should be a secondary permissions screen (during the inappbrowser dialogue) that asks permission for the user's email address.
  2. We'll be pushing out an update that fixes several fields that appear to be null after login (Google email field, Facebook profile_picture field, and 1-2 others).
  3. While not entirely related to this issue, please note that we are working on a fix that will not require your users to re-login all the time with Facebook. See #23

And thank you all for the continued feedback, it's been a huge help.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 22, 2016

@devnetics, no worries. Right now I'm simply taking that info after login and placing it into those areas of ionicUser so I have some consistency across my logic.

However, a larger question is....while I know some things may change as stated in the guides, I am planning on releasing this app in the next week here. How ok are we with doing this?

@ghost
Copy link

@ghost ghost commented Aug 22, 2016

@devnetics will be working with this right now, it just a npm update @ionic/cloud or i will need to make part of the migration that you send?

@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

Hello guys i am a roockie on ionic cloud and i would like to get a code snippet on how to get user's name and picture from facebook . Also a link to the "new" docs would be really helpfull .Thanks a lot !

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 23, 2016

@edjeezy have you implemented the Facebook login?
If you can wait, I would wait for the docs to be released and the api locked down.
But currently you should be able to find the details under the user object in the social property.

Also you can get the image based on the user id.https://graph.facebook.com/v2.7/${user.id}/picture

@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

@sagivf can you give me a sample code

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 23, 2016

@edjeezy Are you using Ionic2 or Ionic1?

@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

ionic 1 but i am going to upgrade to 2 for the production version

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 23, 2016

So code sample For which :) ?

@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

v1

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 23, 2016

I'm using V2 - but I think this should basically work -

Ionic.Auth.login('facebook').then(function(user){
  var name = user.details.name;
  var picture = user.social.facebook.data.raw_data.picture.data.url; // this will defiantly change
});

http://docs.ionic.io/docs/user-usage

But again this is what this ticket is about and will probably change soon so keep following.

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 23, 2016

@edjeezy - I'm using v1 and this works for my app so far. Just waiting on some sample code for implementing the new Push Notifications and Deploy/Check for Updates and I can finally package this thing up for Apple Police review. Have an anxious customer. Let me know if you have any questions.

@sagivf - Good advice to @edjeezy about keeping an eye on the docs.

$scope.FacebookLogin = function () {
$ionicAuth.login('facebook').then(function (_info) {
$ionicUser.details.username = $ionicUser.social.facebook.data.full_name;
$ionicUser.details.email = $ionicUser.social.facebook.data.email;
$ionicUser.details.image = $ionicUser.social.facebook.data.raw_data.picture.data.url;

            $ionicUser.save();
            $scope.loginSuccess();
        }, function () {
            $scope.signupFailure(_info);
        });
    };
@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

Thanks for the support @sagivf . One last question @IndyJones72 can i replace this code
$ionicUser.details.username = $ionicUser.social.facebook.data.full_name;
with this one
$scope.user.username=$ionicUser.social.facebook.data.full_name; for the two way data binding or should i use another method

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Aug 23, 2016

@edjeezy - I don't see why not. The only reason I do it this way is because (correct me if I'm wrong @devnetics / @dwieeb) is $ionicUser is now "global" throughout the application.

So inside of one of my controllers, I do the following (if someone has a better way please chime in):

$scope.user = $ionicUser;

Which will now allow you inside of your template to do something such as:

<div class="item item-avatar">
                    <img ng-src="{{user.details.image}}">
                    <h2 style="color:#333;">{{user.details.username}}</h2>
                    <p>{{user.details.email}}</p>
                    <h5>UID: {{user.id}}</h5>
                </div>

Now again, the reason for this is I have about 14 controllers in this app, but hopefully this makes sense.

@ghost
Copy link

@ghost ghost commented Aug 23, 2016

Hello @dwieeb i was working to make ir work the facebook info but i looks like the problem its not ionic cloud, i update to ionic v2 and when i make a deploy ionic run ios the app does not update at all, so i think that its why i cant see the social object.

So did you have an idea why does this happens or how can i fix it? i was looking around but there is not so much information about ionic v2, do i have to make a downgrade of my ionic to fix the problema?

Thanks, i'll keep looking around for an answer.

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 23, 2016

@ArkangelB Just so you know, I've always had problems with ionic run ios usually doesn't work for me. I use the emulator or run it through xcode (xcode doesn't always run smoothly either).

@sagivf
Copy link
Author

@sagivf sagivf commented Aug 23, 2016

There are so many variables to this - Ionic cli version, cordova version, node version, ionic version, ios-deploy, ios-sim, os version, plugins, xcode version and probably more :)

@ghost
Copy link

@ghost ghost commented Aug 23, 2016

@sagivf haha it's the first time that i have problems with ionic run ios but i know what you mean, i just make a package just to know if facebook social object its working and it works so i'm happy 👍 now i can keep working with the next stage..

@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

Can i know when the 'updated' docs will be available ?

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 23, 2016

Facebook and Google fixes are live now, the null fields should be corrected. We also pushed out a fix where in some cases Google email wasn't getting fetched properly.

@edjeezy We're working as fast as we can to get the updated docs out. The wait shouldn't be too much longer.

@edjeezy
Copy link

@edjeezy edjeezy commented Aug 23, 2016

@devnetics thank you for the hard work . Ionic is really a dream came thrue so keep on going .

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 23, 2016

@edjeezy Thanks! It means a lot to us to hear that.

@ghost
Copy link

@ghost ghost commented Aug 23, 2016

@devnetics i have a question i can have the image from facebook like this

$scope.imgProfile ="http://graph.facebook.com/v2.7/{user.id}/picture"

and it get the same photo quality that the picture that you bring to the object but if you ask for this one

$scope.imgProfile ="http://graph.facebook.com/v2.7/{user.id}/picture?type=large"

it gets a much better quality, so my question is, it exist a way that we can ask for a better photo quality?

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 23, 2016

@ArkangelB I see what you mean. I'll look into it. The base url we provide from facebook doesn't give you that capability at the moment.

@ghost
Copy link

@ghost ghost commented Aug 23, 2016

@devnetics ok this still works pretty nice!

Thanks for everything!

@olivercodes
Copy link
Contributor

@olivercodes olivercodes commented Aug 26, 2016

Hey guys, we are going to ahead and close this issue. We are still making small tweaks/updates, nothing breaking. We have taken into account all of the feedback and will be iterating on this feature further after release of the new docs. Please report any actual errors in a new issue.

@cfjedimaster
Copy link

@cfjedimaster cfjedimaster commented Mar 6, 2017

Just checking in - was this addressed?

@IndyJones72
Copy link

@IndyJones72 IndyJones72 commented Mar 6, 2017

@cfjedimaster - Yes it sure was. We were able to get the basic profile information needed, but I believe there's some additional information brought back which could be helpful as well now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants