Identity server 4 with Google sign-in button

Viewed 185

I can`t integrate Identity Server 4 with Google Sign-in button.

Once I got success callback from google widget, how can I get logged in to Identity Server?

gapi.signin2.render('spGoogleBtn', {
                    'width': 240,
                    'height': 50,
                    'longtitle': true,
                    'theme': 'dark',
                    'onsuccess': function (googleUser) {
                        //what is next here?
                    },
                });
1 Answers

Here is the callback from the Identity Server 4 Quickstart: https://github.com/IdentityServer/IdentityServer4.Quickstart.UI/blob/main/Quickstart/Account/ExternalController.cs#L81

I'm using a slightly modified version of this in my projects.

I just followed the official documentation here: https://identityserver4.readthedocs.io/en/latest/quickstarts/2_interactive_aspnetcore.html#refexternalauthenticationquickstart

If you want to roll your own, you have to:

  • issue a temp cookie when you load the page where the widget is located
  • then on success you call the backend and use the temp cookie to verify the request.
  • then you authenticate the user (you may have to create a new user).
  • then delete the temp cookie and then redirect to the return url.

It's quite a bit of work.

Related