ionic-team / legacy-ionic-cloud

JavaScript Client for legacy Ionic Cloud services. See Ionic Pro for our new take on the ionic development lifecycle
Apache License 2.0
65 stars 26 forks source link

Social Login not collecting user info #20

Closed sagivf closed 8 years ago

sagivf commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

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

sagivf commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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

IndyJones72 commented 8 years ago

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

ghost commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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

IndyJones72 commented 8 years ago

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

sagivf commented 8 years ago

@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). 2) 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. 3) 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). 4) 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 commented 8 years ago

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

olivercodes commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

@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!

ghost commented 8 years ago

@dwieeb Thank you i'll be wait it for your npm release!

imhoffd commented 8 years ago

@sagivf @IndyJones72 @ArkangelB I just published to npm! Please test social auth user data. Some things have changed--deploy in particular. Please see this diff of the migration guide for more details.

IndyJones72 commented 8 years ago

@dwieeb - On it! Will report back.

ghost commented 8 years ago

@dwieeb awesome! will be in touch!

IndyJones72 commented 8 years ago

@dwieeb @sagivf @ArkangelB - Installed latest npm, however can't get to the login page of twitter or Facebook. Anyone else having issues? I didn't change anything and my team didn't commit any new changes, so it should be the way it was always working. Did I miss a change to the login? Here's my current way I call the login....

$scope.FacebookLogin = function () { $ionicAuth.login('facebook', { 'remember': true }).then(function (_info) { $scope.loginSuccess(); }, function (_info) { $scope.signupFailure(_info); }); };

Am I missing something that has changed?

imhoffd commented 8 years ago

@IndyJones72 Looks correct (but you should remove {'remember': true} as it has no effect).

What are you seeing? It should resolve or reject that promise. Any errors?

IndyJones72 commented 8 years ago

@dwieeb - Ok removed that and still not reaching it. I'm going to reboot....see if that makes any difference and then see if I can't capture any errors via the console or Safari and report back. Probably something on my side, but did want to reach out and see if anyone else was having any issues before heading down that all-too familiar rabbit hole of my own stuff breaking it.

IndyJones72 commented 8 years ago

@dwieeb - Ok rebooted and only on the Twitter login am I seeing some type of error which is the InAppBrowserPlugin missing. Which is strange since it was working earlier today. I installed it again via npm and still no luck.

In the network tab of the debugger, I don't even see it trying to make the call to the service...so that in itself is strange. Not a network issue since if I login via my non-social method, works just fine and the app works as normal.

imhoffd commented 8 years ago

Did you do cordova plugin add cordova-plugin-inappbrowser --save?

ghost commented 8 years ago

can somebody help me i'm trying to do the update but my npm update fails someone have the same issue? or can somebody tell me what am i doing wrong updating?

imhoffd commented 8 years ago

@ArkangelB What is the command you're running and the error message?

ghost commented 8 years ago

@dwieeb Sorry i get too busy last night, i'm running 'sudo npm update' OSX El Capitan, and i send several error the first one said:

fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make: *\ [Release/obj.target/binding/binding.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)

I can attach the error file if you need it.

*I only have a couple of months using Ionic and npm so it might be a rookie mistake the way i'm updating.

fknop commented 8 years ago

@dwieeb thanks for this feature. Working for me with Google+.

imhoffd commented 8 years ago

@ArkangelB I'm not sure what all that's about. Try updating just our package. npm update @ionic/cloud

@fknop Awesome, glad to hear. 😄

ghost commented 8 years ago

@dwieeb haha sorry man i really was too busy and don't even look the entire document that you make for us, an apology i will initiate the update 👍

Thanks for everything!

ghost commented 8 years ago

Hello, It exist a typo error at the tutorial, you change ionic.cloud.min.js for ionic-cloud.min.js so it does not load the module because not exist that file..

imhoffd commented 8 years ago

@ArkangelB Thanks, fixed that in the migration guide!

ghost commented 8 years ago

hey @dwieeb i was trying to get Social Profile information from Facebook i can't find the data.. this is what am i using:

$scope.facebookLogin = function() { $ionicAuth.login('facebook', authSettings).then(success, failure); };

Everything works as usual but i have no data to display for social provider, when i use ionic run ios -l and watch my console info showing $ionicUser. (Safari console)

from safari ios debug

If i do a basic login it shows user info custom you can see differents kinds of objects between social and basic info. (Chrome console).

from ionic serve chrome

Does anybody has been able to get data from Facebook? you were trying with facebook right @IndyJones72 have an idea why is not working with me?

olivercodes commented 8 years ago

@ArkangelB Can you fully expand that social object and post here with what it contains?

IndyJones72 commented 8 years ago

@ArkangelB - Correct, I had Facebook and Twitter both "showing" the data coming back in the version just before this latest NPM. I just didn't have the new version where that would get placed automatically into the $ionicUser.social.

However, for some reason since then I haven't been able to get Facebook or Twitter to open in the iOS Simulator or on an actual iPhone 6 Plus.

I'm going to pop Google Plus on there and see if that works, if not, I made a backup just prior to the npm update so I'll go back into that folder, and retrace steps to see what the hell happened.

IndyJones72 commented 8 years ago

@dwieeb @devnetics - Ok I found what the problem was. Coming from the ionic-platform-web-client and following the migration guide, I didn't uncomment this line:

<script src="cordova.js"></script>

...which I know is stated in the index.html file, but maybe it can be put as a reminder into the migration docs for twits like me?

So @dwieeb / @devnetics - when I close the app and reload it...it knows I was already authorized by FB and bypasses my login area. However, going to the account page where my social data is, the $ionicUser.social is empty. So.....what's the best way for making sure that data is populated so I can show their avatar/image, username, etc?

imhoffd commented 8 years ago

@IndyJones72 Sorry for the confusion. The new deploy plugin does require the cordova.js include to be there. I fixed the migration guide to clear that up.

@IndyJones72 @devnetics I will look into this tomorrow. The social data should be persisted into local storage. If it isn't, no problem, I'll add that logic. It will be simple. Thanks for your patience during this beta period and migration process.

IndyJones72 commented 8 years ago

@dwieeb - No worries. I made a decision for my company and my customers over a year ago after doing over a year of research of various multi-platform frameworks to commit to Ionic as the only one I allow my devs to use. So we see your commitment and communication as a sure sign that I made the correct decision.

Keep up the great work and thanks for looking into that persistence.