https://github.com/runthis/laravel-google-auth
Tiny authentication in Laravel with Google for a specific domain
https://github.com/runthis/laravel-google-auth
authentication google laravel
Last synced: about 1 year ago
JSON representation
Tiny authentication in Laravel with Google for a specific domain
- Host: GitHub
- URL: https://github.com/runthis/laravel-google-auth
- Owner: runthis
- License: mit
- Created: 2022-06-28T17:17:38.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-30T22:59:24.000Z (about 1 year ago)
- Last Synced: 2025-03-30T23:27:17.604Z (about 1 year ago)
- Topics: authentication, google, laravel
- Language: Blade
- Homepage:
- Size: 92.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Google Authentication
A tiny laravel package to authenticate users via google with domain verification.
## Installation
composer require runthis/laravel-google-auth
## Setup
##### Google
Head over to https://console.cloud.google.com/apis/credentials and set up some oauth credentials. Note the client id.
##### Laravel
Open up your .env file and add the following keys and adjust as necessary.
GOOGLE_CLIENT_ID="xxx.apps.googleusercontent.com"
GOOGLE_BASE_ROUTE="/login"
GOOGLE_AUTH_ROUTE="/auth/callback"
GOOGLE_VALID_DOMAIN="domain.com"
With the above environment variables; When a user visits /login in your application, they will be presented with a page containing a button to sign in with Google.
## Usage
Package emits `Runthis\Login\Events\UserWasAuthenticatedWithGoogle` when google login is successful and contains an array payload with various keys provided by google (name, email, picture, etc).
Create a listener in Laravel. Add `use Runthis\Login\Events\UserWasAuthenticatedWithGoogle;`. Set the handle method parameter to `UserWasAuthenticatedWithGoogle $event`. Handle the event as you want (logging the user in, adding to database if you like, etc).
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.