How to force login to oauth with specific email address? - oauth-2.0

Lets say I want a specific user to login with a specific email address.
dave.myservice.com --> dave#example.com
So, if you accessing this page "dave.myservice.com" , I want my application to make him log in with dave#example.com, not with his other personal accounts.
Is this scenario possible?
Thanks in advance!

For Google OAuth, you can use the login_hint parameter to specify an email you would like the user to login with (cf https://developers.google.com/identity/protocols/oauth2/web-server#creatingclient)

Related

Can we get email Id from Facebook application?

Can an application check if anybody is logged into Facebook application in mobile ,if logged in get the user email Id from that and use it in their application?
To get a logged in users email address, you would have to authenticate with the API and the user would have to approve you using the Oauth workflow.
You can display a customized login / connect button using the Facebook API but if I recall correctly, that is an iframe that is embedded in your page, and you never see the email from that.
tldr; No. You need to authenticate using the Oauth workflow and have the user grant you permission.
First you have to authenticate user and then you can get logged in user profile information. For that you have to use Facebook API. Please check below link.
https://developers.facebook.com/docs/facebook-login/ios/v2.2

Identity 2.0 Linking Multiple Login Providers

I have finally managed to implement Facebook as an external login provider on my MVC website which seems to be working fine, but I am wondering what is the correct / secure way to allow multiple external login provides to be linked to a single account.
Lets say I login with my facebook ID, no existing account is found with the same email address and my website persists a new account with their email address and their facebook token etc associated.
Next day I login with my Google account, If i check my database for an account which already has a matching email address what should I do?
1) Link this Google account with the existing account automatically and
log them in?
2) Ask the user if they wish to link their google account to the
already existing account we found?
3) Something else?
Thank You.
It is really up to you. But the default provided in the VS2013 template assumes a one to many relationship between your internal user and any external logins. If you retrieve a user with UserManager, you will see a IList for each external provider the user has logged in with.
As they log in with the new provider, you would normally not automatically know the user is associated with another provider's login. When you login it looks up a user via external ProviderKey, so initally would not find any relation to an internal user. At that point you could search users by name, email (with customized user store) and so on to link as needed.
Assuming primary emails registered on facebook and google for example, are verified by them (which they usually are) I don't see any issues on linking them together.
I think the main problem is linking internal account with email that was not verified to be from specific user. If i create an account with email of other user and that email is not verified, when the other user creates an account it associates the data of the first user together and that way both users are using the same account.
Can anyone identify and explain potential flaws for my first claim please?

Login with Email/GMail in ios

I want to add "Login with Email" functionality in ios app.
I searched about this, but i found that we can not get default email account of iPhone.
Can anybody suggest me how should i proceed for this issue. Thanx in advance.
use this link for your login with gmail http://technogerms.com/login-with-google-using-oauth-2-0-for-ios-xcode-objective-c/
will u need just like this , here i used
Login with FB
Login with Twitter
Login with manually
-- here i used server and Sqlite for save the user information
-- email, name, p/wd, phone number, etc.
-- this login accessing with our own db or server
Of all the apps that ask for email and password, none get it directly from the iPhone settings, which makes me believe that there must be some sort of restriction for gathering that information.
So, then the procedure is ask for email and password from the user directly, fire a url to validate and check for the user with those credentials and either login or ask him/her to sign up

devise sign In user automatically based on authentication_token

Is it possible to send an email with a user with a link that automatically sign him in based on authentication_token or something similar? (No login required).
Sure, it is possible. Just send a link to login with a query string containing the username that should be logged in. When your login code gets this, sign the user in.
Just be sure to generate a unique token instead of just using email/username
And also you should tell users that the link can be used to sign in since they might forward it to others.

How can I force login with the OAuth API?

Is there a parameter I can pass to https://www.facebook.com/dialog/oauth that will force the user to login again?
The problem is if the user is logged into Facebook, it will redirect transparently back to my site, even if the user wants to use a different Facebook account.
Twitter's OAuth API accepts a "force_redirect=true" parameter which does what I want, but I can't find one for Facebook.
I think "auth_type=reauthenticate" is the option you are looking for.
Docs: https://developers.facebook.com/docs/reauthentication/

Resources