Question

I'm currently using Google Authentication to allow users to sign into my application, but there a couple of things I want to do to go further and I am unsure how to do so.

The first thing is to only allow email addresses from a specific domain so that only registered users of that domain can log in to the application, so for example you wouldn't be able to login with an "@gmail.com" account. (The domain allowed is that of my univerisity which uses Gmail.)

Secondly, when you log in it will say "Welcome Google:0000000000000" (replace 0s with actual userId), but I want to use the users name. When you authenticate the app to use your Google account it says you allow it to access your basic information, which I assume includes your name, but I don't know how to then use someone's name.

I have used this Azure tutorial and so a lot of the code isn't within my application.

Any help would be greatly appreciated and if you have more questions just ask.

Était-ce utile?

La solution 2

I have found the answer on high to retrieve the user's name for storing in the database along with some other useful information regarding my second request here: http://blogs.msdn.com/...

Regarding the first issue I got a response from a Microsoft representative that said the following which I will look into.

What you can do is to create a "dummy" table that, after you login, you make a call to that table (can be any of the operations) and on the script for the table operation (choose one of insert / update or read) you validate the e-mail. In the future we may make this process easier.

Update: So, there is an issue in with their Google authentication code - you will get some basic information about the user, but the e-mail is not one of them.

Autres conseils

If you are using oauth. Then in the oauth request you can add "hd=domain.com" and it will restrict authentication to users from that domain. Here is an example: Google client API - limit oauth authentication to my domain. If you are not using oauth please specyfic more information about authentication type.

I'm assuming you are using oauth and already got a token. You can get user's username with endpoint : https://www.googleapis.com/oauth2/v2/userinfo with scope: https://www.googleapis.com/auth/userinfo.email. Here you can do some tests. More details how to do it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top