When using OAuth we are using a third party to take care of the authentication of a user.
E.g. when using Facebook we “register” our app with Facebook and when a user of our app tries to login instead of providing to the app his credentials he logs in using his Facebook account.
What I don’t understand is why does the app trust the user? All the app knows is that the user is trusted from Facebook as he has an account there. How can we trust that the user should really access the app?
In this case the "user" you are providing services to is the Facebook/Google/Instagram/etc. account. From your perspective, you do not care who the person typing the credentials in is.
Normally, all you know is that the person who logs into your app knows the user name and the password for the account. In the external validation case, you know what the person has this specific login for fb/google/inst and knows the password associated with it.
Please keep in mind than in most cases (local or external validation), you do not know the person associated with the account (unless you have some method of personal validation, like credit card or sending a traditional letter with some auth). All you know is that the person who logged in knows the credentials.
Technically, each of those accounts (fb, google, inst) is a separate "user", and your local credentials login is a different one yet.
The whole concept is about user convenience really, plus some additional benefits like having the user data stored and maintained by someone else, additional security and so on.
That said, it is still totally fine if you stick to the "local" credentials method, just make sure it is secure :-)
EDIT:
A simple example:
Your app has two login options - a simple login with password and login with Google.
You also have a user, John Smith.
John opens your app, which requires login and has some sensitive data connected with each account.
Scenario 1. John selects standard, "local" login option and logs in using his credentials JohnSmith1111 and password 12345. John is now able to display the data associated with the account JohnSmith1111.
Scenario 2. John selects log in with Google. He is redirected to the login page, authenticates there and returns to your app. Your app is notified that the user google_john_smith has successfully authenticated. John is now able to display the data associated with the account google_john_smith.
The point is that the account validated using those login options is not the same! There is no "trust" issue here.
Related
so here's my situation. I'm trying to build a very basic app on Android Studio that requires a sign in and a registration page. Both pages prompt the user to insert their username and password. What I want to happen next is that when a user goes to the registration page and inserts a username, I want the program to check if it's unique or not. If it is, I want the program to essentially store the registration data for future use. So when a user wants to sign in, they can only sign in using a registered username, and they can only access the account if it's accompanied by the right password. I tried looking up tutorials online, but I couldn't find anything that fits what I'm looking for. Any ideas?Tips? Tutorials? Pointers? All would be greatly appreciated.
When the app successfully logins in via Facebook it begins to save the credentials. This should ask the user if they want to save it with SmartLock or not, but it's being saved automatically.
Inside the save callback I get a success with no resolution. It should not be a success, and it should contain a resolution to allow prompting the user to save.
Is there any reason why this is, or any way to get the functionality I want?
-Thank you
Password-less "credentials" can be saved without needing to prompt the user (i.e., credential built with .setAccountType in place of .setPassword) if the identifier on the credential matches a Google Account on the device.
And in general, when the user returns on another device, user can be immediately signed back in if they are using an account for the app that matches one on the device, since such credentials will come with a token you can use for auth. For example, gmail user whose account is active on a device (and could otherwise receive email, such as for a password reset flow), can be signed in to apps without need extra UI or to trigger a Facebook flow unnecessarily to get a different token.
In the past, the API required prompts to save any information, but we found in user research testing that minimizing the dialogs users encounter reduces confusion, streamlines the user experience, and promotes security best practices (such as using tokens from authoritative issuers when relying on email-based identifiers).
I'm trying to integrate an existing login system for a mobile application with some social media sign-in solutions. I successfully managed to integrate both facebook and google+ sign in with my app and I get to the point where the users are signed in and I can get their social information.
But now I was left wondering which would be the best approach in order to integrate users that decided to use a social media account with my native login system. Should I use their email accounts as login and maybe generate a password on the server side? Or maybe use an oauth token instead of a password?
I need to keep track of my users, even the ones that did not formally filled a registration form. So what should I place instead of email + password?
This can be tricky - the majority case is easy, but you need to think about the edges. I find it easer to consider email/password as just another authentication mechanism. You want
A user record with the core data about that user (perhaps name, email address, app specific profile data etc.)
A series of records for their connected auth methods, e.g. Google+, Facebook, user/pass.
The connected auth methods can store the relevant information for those methods - e.g. for Google it would likely be Google user Id and perhaps refresh token if using offline access. This makes it easy for you to offer connecting multiple social accounts.
Password may be a special case that you want to store against the original user record. In that case, if someone signs-up using a social login, then you can either generate a random password, or leave it null. Either way, as long as you request the email address for the user, you can always let them go through a Forgot Password flow (where you generate and email them a password) if they want to access their account but no longer have their 3p login.
What you don't want to do if avoidable is to force the users to give you a new password just after they sign in. However, it you are allowing multiple login methods to be associated with one account, you might want to allow associating them. So, your flow might be:
User signs in (with 3p or email/pass)
If you have a record for that login method (e.g. matching Google or Facebook user id, matching email/pass combination), sign the user in, and you are done.
If you have no matching record for that sign in method:
See if you have a matching email address with an existing user account. If you do, some sites automatically merge the new login method to this account. If privacy/security is more of a concern you might want to confirm the user wants to login to that account, or make them go through a 1-time validation (e.g. "it looks like you've signed in with a password before, please enter your password now to link your account and your Google account" etc.). Then link the accounts and continue as if signed in.
See if you have an account which may be that person. E.g, perhaps you have an account with a matching name. In that case, you might want to hint the user to connect their accounts (e.g. a prompt somewhere that says "have you connected before with Facebook? Click here to link these accounts" which then takes the user through a sign in process for the login method you suspect they might have).
If they look totally new, create a new user record, and treat them as newly signed up.
Its significantly easier if you can treat email address as a unique field. That means if someone signs in with a 3p account associated with an email address you already have a user for you might have to force them to link their account before continuing. If they didn't want to and you required an email address, you could prompt them to enter one manually and then validate it as normal by sending them an email and having them confirm it.
ChrLipp's links are good, also take a look at the guide for using FB and G+ together on the Google Developers site: https://developers.google.com/+/best-practices/facebook
How did you implement the social media sign-in's? For example Facebook: did you use Login for Android? In this case the docs say under Checking login status:
Apps using our SDKs can check whether someone has already logged in using built-in functions. All other apps must create their own way of storing when a person has logged in, and when that indicator is not there, proceed on the assumption that they are logged out.
And if you follow the link to Storing access tokens and login status you can read:
The token should be stored so it's available to all parts of the app when it makes API calls. ... If you're building a ... mobile app, then you should use the datastore available to your app. Also, the app should store the token in a database along with the user_id to identify it.
Have an enumeration (NativeLogin, Facebook, GooglePlus) and depending on this enumeration the following information:
NativeLogin
UserName, Password
Facebook and GooglePlus
Facebook or GooglePlus ID and their User Access Token
In all cases you should store the email adress you get in an additional field.
I have a question about the Login with Facebook feature that some apps have. Here's my scenario:
I currently have an Android social networking application that has its own user database and login system and users have their own username, bio, etc, and I would like to include the option for Facebook login. Currently, when a user wishes to sign up to use the app, they have to enter a new unique username/password/email and that username is then used for further requests to the database from the app and is required. So basically I have a few questions:
I know I can get the FB email for a user and use it in the sign up process but what about the username/password combination - should I ask for them separately?
Assuming that the sign up with FB is complete, when the user logs in with facebook how would I know the username? (I am guessing that I could use the email address to verify this, right?)
So I guess my main problem is how to get a username/password combination upon signup/login from facebook. Any help/suggestions are much appreciated :) Thanks
(I know that this has probably been asked a million times before but I couldn't find a good explanation/resolution to the problem and since I have a username, instead of an email address, as the user identifier, I think this complicates things a bit)
Answering to the question 1, I'd say that the Facebook password, will be the password you are talking. Just that Facebook will store it, so you must allow to the Facebook users, to not have a password on your database.
The question about the username, it's more complicated to answer, and I guess that should be you who has to answer it. But I'll use his/her Facebook name, as I saw on many applications I use Facebook login.
So, as a resum:
The email, will be the one which is related to the Facebook account
The username, will be the name related to the Facebook account
The password, will be the password related to the Facebook account
So, you have a problem right now at your database, because you wanted a unique username, password and email. Right now, you could have duplicateds, since it could be possible that a user uses his email and his Facebook account(with same email). So, I'll use either 2 tables, "FacebookUsers" and "Users" either a unique table with a new field, that will distinguish the Facebook users, and the regular users.
Right now i develop simple app that require login to my app (not login twitter), and he/she can look our collection and can share it into twitter. In setting there is option to login twitter and i use Twitter4j with this tutorial. My problem is :
if Person A login into my App and login Twitter and share content and then Logout my App without logout the Twitter
how can i detect if Person B login into my App and want to login Twitter (using same device with Person A) ??
do i have disconect twitter Person A and than connect Person B ??
If I disconect twitter Person A, and maybe Person A login again to my App , i dont want he/she do login Twitter again, i want automaticly..how can do that with twitter4j??
sorry i my qustion hard to understand, my english is bad ><
It is very difficult to understand but I shall try my best!
Note, this is just an example, there are many ways, better and worse than what I am suggesting so learn, research and good luck!
Now, to do what you're asking for build your application along these steps:
Create a collection of your preference that accepts some ID and access token object and save the collection permanently via a method of your choice, for use every time the application starts.
When a Person logs into your app and then twitter, save that Persons access token for twitter with that Person as its ID into your collection.
Re-save your updated collection.
Next time a Person logs in, simply check to see if they exist within the collection:
If they do? Go ahead and auth them with the access token stored.
If they do not? Go ahead and fire up a new twitter auth process when they need twitter services.
This way no matter how many users use your app on that same device, each twitter access token will be saved and only accessible by the appropriate user.
Also, As far as I am aware, to "log out" of twitter is as simple as deleting/throwing away the access token object relevant to the user wanting to log out.
Hope this helps.