How to login with google in Drupal 8 & 9
Login with Google is quite simple. All you have to do is install the module and create a google project and enable API and services to get credentials (client secret and id). The social_api, social_auth module should be installed along with social_auth_google. The best way to install and manage Drupal modules is composer.
Go to your Drupal site root or wherever your composer.json for the website is and run the following commands :
composer require drupal/social_api composer require drupal/social_auth composer require drupal/social_auth_google
Enable both the modules and go to the social_auth config (admin/config/social-api/social-auth) and click on the Google tab. This is what it would look like :
Fill in this form with the values from your google project that you created in the google cloud platform. If you don't have a project, create one at this link https://console.cloud.google.com.
After you create a project, you have to get your Client ID and Client Secret. Go to APIs and Services, and add credentials for OAuth 2.0 :
Now you should be able to login with google with the URL 'http://yoursite.com/user/login/google'. or if you want to add button login with google, just add "Social Auth Login" Block to a region like this:
Also to test on a local machine, add your local URL as well to the OAuth redirect URLs.
I hope you found this article useful. let me know if you have any questions and I’ll be happy to answer them.