Post/Code

HomeAboutUsesNow

Google OAuth with Auth0.

Auth0's "silent authentication" feature enables you to automatically log users back into SPA's (single page applications) after a page refresh. If you are using the default username and password authenticaiton functionality, then, if the user is logged in when the page refreshes, the "silent authentication" will automatically log the user back in on page refresh (whether running on localhost or on the internet).

When you activate the Google social login (OAuth) on Auth0, which enables the user to log in via Google with their Google details, the user will not be automatically logged in on page refresh. At first I thought this was due to some kind of misconfiguration on my side. However, on further reading, I found that is was because my app running was on localhost. Once I had deployed my app to Heroku however, the Google login still did not automatically log the user in after page refresh.

As it turns out, the auto-login does not happen because Auth0 is using their default Google OAuth developer keys. In order to enable the "silent authentication" feature with Google logins, you need to enable your own Google API details.

Fortunately, Auth0 provides a useful tutorial explaining the process and it is very easy to setup! Once all done correctly, your Google login will correctly login automatically after page refresh.