I have a "sign in with Google" button in my web application, and I want to get the email address entered by the user before sending it to the Google API. Thoughts?
Asked
Active
Viewed 63 times
0
-
hmm, I don't think so. Can you explain to me? why you need email. – Vikash Saini Mar 28 '19 at 05:46
-
this might help https://stackoverflow.com/questions/24442668/google-oauth-api-to-get-users-email-address/24510214 – Madhawa Priyashantha Mar 28 '19 at 05:49
-
@VikashSaini I want to check if a user has registered in the application using the same email address. – Rukshala Weerasinghe Mar 28 '19 at 06:00
-
@RukshalaWeerasinghe But you can check after getting the response from google auth and verify it in the database once you get a response. If User is not using the same id then you can just add new id in the database also. I believe this correct implementation of this feature. – Vikash Saini Mar 28 '19 at 06:29
1 Answers
0
Is there a way of getting the email address entered by the user before sending it to the Google OAuth 2.0 API?
No its not. The login screen where they typing this in is on Google system. Google isnt going to send you that back until the user has approved you knowing this information.
The only way to get the email address of the user is after they have signed in. Assuming that you have requested the email scope the userinfo endpoint will return this information to you. Some of the Google apis also have an endpoint which will return information about the current users account and this often includes their email.

Linda Lawton - DaImTo
- 106,405
- 32
- 180
- 449