S
S
Station 722020-03-12 09:26:30
Google
Station 72, 2020-03-12 09:26:30

How to register a user with google account?

How to implement registration and login to the application through a google account?

Now we have implemented only for FaceBook - everything is simple here, we enter data, get json in response, take a token and send it to our server. On the server, we go to Facebook and get the user by the token, take the mail and write to the database. At the exit, we give cookies with which the user runs to us.

I would like a similar mechanism for google accounts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Station 72, 2020-03-13
@cjstress

Here we register the application and take the keys
https://console.developers.google.com/apis/credentials
We receive data about the user on the client.
On flutter, the google_sign_in library, but it is also possible for other platforms
Helmet to the ID Token
server On the .net server, install the Google.Apis.Auth library from nuget

GoogleJsonWebSignature.Payload googleUser = await GoogleJsonWebSignature.ValidateAsync(idToken, new GoogleJsonWebSignature.ValidationSettings()
                {
                    Audience = new List<string> { googleSettings.AppId }
                });

googleSettings.AppId is the data that we received from the link above
idToken is the data from the client

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question