Login with Google

Social login using your personal Google or Google Gsuite account is a common use case for many login scenarios.

# Steps

  1. We start at a site that offers Google as an authentication provider. In this case we use Stack Overflow (opens new window).
  2. We fetch the login page and click the "Login with Google" button.
  3. We are redirect to Google.
  4. We provide the username and password, injected by using environment variables.
  5. We are redirected back to the starting.

    Run this example as follows. Replace the username and password placeholder with your own credentials.


      This example does not work when you have 2-factor authentication enabled, and you might trigger a recaptcha check.

      # Takeaways

      1. Use environment variables to inject secrets.
      2. Wait for the navigation as your are redirected to Google.
      3. Wait for the navigation as you are redirected back to the start site.