how to check/get the current session google account name - asp.net

I want to check whether any google/gmail account is logged in current session. if not just redirect to the log in page, else retrieve the gmail id. is their any posibility to do like this?
Updates
Using Google api v3 to connect with the calendar; am not able to creating connection if another google account is logged in in current session; so i need to check whether any google account is logged in the current session;if yes get the gmail id; if not then it will work fine

Related

How to get ID of disabled firebase user (during authentication)?

If I disable a user from console user credentials will not be refreshed in one hour and user will be deauthenticated. Upon trying to log in, user will get the FirebaseException with the ErrorCode AuthError.UserDisabled.
Showing the user that his account is disabled is good, but I also want to show him his firebase account ID (which is a complex string with letters and numbers) for support inquiries. How can I get the user Id to show it to user when the account has been disabled? This is happening in Unity.
As far as I know the UID matching the credentials is not exposed in this error message, so you will have to look it up another way. The best I can think of is using the Admin SDK to find the user by their email address.

Firebase: Link facebook account with existing user

I have a current database with active users in Firebase that can login with user/pwd but now I'm implementing the facebook login and I realised the only way to link a facebook account with an existing user is only when the user is already logged with the user/pwd but not before the login.
I have two buttons in my app (login with fb and with email) but if I try to login with fb using the same email of an existing user, I will receive the following error auth/account-exists-with-different-credential and the documentation says that in order to fix this the user needs to login first then link.
Do you know if there is a way to link both accounts but without perform a login first, I mean, from the login view?
You need to sign in the user first before linking. This is important if you want to ensure it is the same user. Otherwise you can switch to multiple accounts per email in the Firebase console.
The way to solve this, when you get the error auth/account-exists-with-different-credential, the error will contain error.email and error.credential after you sign in with Facebook and the account already exists as a password account.
You then call firebase.auth().fetchProvidersForEmail(error.email) to which resolves with the list of provider IDs for that email. In this case, it will contain ['password']. You then ask the user to provide their password. You call signInWithEmailAndPassword(error.email, password) to sign-in the original user. You then call firebase.auth().currentUser.linkWithCredential(error.credential) to link the Facebook credential to the password account. Now both accounts are merged and the user can sign in with either.
I fixed it by going to the Firebase console. then head over to the authentication section and select the Settings Tab. Afterwards, go to User account linking and check Create multiple accounts for each identity provider

Firebase : Authentication providers different email address

If I register with Facebook (x#x.com) and later log in with Google (y#y.com), but I do not have the same email address on both providers, there are 2 users created. How can I handle this situation?
Linking is typically used in three cases:
Automatically requested by the backend for security reasons: when a user signs in to google for example with email x#x and then logs out and tries to sign in with a new facebook account x#x. In this case the backend will not complete the second sign in without verifying that the second user is the same as the first user (since both use the same email). So in this case, the user has to sign to the google account and then link the second facebook account to the initial one.
Manually triggered by the developer: One common case here is that the user signs in to google with email x#x and remains signed in. The developer wants access to the user's facebook friends. So the developer will ask the user to link their facebook account to the already logged in google user.
Upgrading an anonymous user: Developer could automatically sign in users initially as anonymous and then prompt them to upgrade to a registered user. In this case you can call link on the anonymous user.
So auth.currentUser.link can be made on all kinds of users as long as the account you are linking is new and not already linked.
You'll want to use the Account Linking APIs to authenticate multiple providers for the same account. Docs for Web, Android, and iOS are available.

Obtaining Google user ID in ASP.NET MVC4

Folks,
I just started to work on an ASP.NET MVC4 web application. I added support for local login as well as login using Google ID (using OAuthWebSecurity).
It seems the user is successfully able to login using Google ID. When I examine Membership.GetUser(), I see that the user name for the logged in user is the Google email ID.
As the user can log in either locally or using Google ID, I need to have the ability to query my local database using either the local user ID or the Google ID.
I am trying to understand what Google ID is. Is it the email address of the user or is there a unique GUID associated with each Google user. I am guessing it must be the latter case. If it is, how do I obtain this Google ID? I don't see any property on Membership class that gives me this information.
Thank you in advance for your help.
Regards,
Peter
The username for google is the email address. This is an OpenID account.

Facebook API, Using FB Connect on email address

ASP.Net C# and FaceBook Connect.
I'm using Facebook connect on my site. If a new user connects through FB i create an account for them and all is fine. What i would also like to do is check to see if they already have a registered account.
So if someone connects that has not logged in but has an account i would like to be able to locate the account in my application a link it. I hoping this could be done via the email address?
Any ideas
Thanks
Richard
UPDATE: You need Connect.registerUsers:
This method is used to create an
association between an existing user
account on your site and that user's
Facebook account, provided the user
has not connected accounts before.
This method takes an array of account
data, including a required email_hash
and optional account data. For each
connected account, if the user exists,
the information is added to the set of
the user's connected accounts. If the
user has already authorized the site,
the connected account is added in the
confirmed state. If the user has not
yet authorized the site, the connected
account is added in the pending state.
If the user deactivates their external
user account, then call
connect.unregisterUsers. To get the
number of friends a user has in the
pending state, use
connect.getUnconnectedFriendsCount.
If that doesn't resolve your question, this question is not a duplicate of yours, but the answers might give you a way forward:
How do we register users — Facebook Connect users logging in the first time — when we cannot get an email address from facebook?

Resources