Package Data | |
---|---|
Maintainer Username: | danjdewhurst |
Maintainer Contact: | jacob@mirk.co (Jacob Morris) |
Package Create Date: | 2017-07-06 |
Package Last Update: | 2019-12-11 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-05-08 03:00:45 |
Package Statistics | |
---|---|
Total Downloads: | 24,018 |
Monthly Downloads: | 209 |
Daily Downloads: | 5 |
Total Stars: | 28 |
Total Watchers: | 7 |
Total Forks: | 21 |
Total Open Issues: | 2 |
Provides a new Laravel Passport Grant Client named facebook_login
, allowing you to log a user in with just their Facebook Login token.
A new user will be created (and optionally assigned to an role - $user->attachRole(ID)
) if the email address doesn't exist.
Install with composer composer require danjdewhurst/laravel-passport-facebook-login
. Use major version 1 for Passport 4 and below Laravel 5.6 compatibility.
5.0||6.0||7.0
5.6
Danjdewhurst\PassportFacebookLogin\FacebookLoginGrantProvider::class
to your list of providers after Laravel\Passport\PassportServiceProvider
.Danjdewhurst\PassportFacebookLogin\FacebookLoginTrait
Trait to your User
model (or whatever model you have configured to work with Passport).php artisan vendor:publish
, this will create a config/facebook.php
file..env
file: FACEBOOK_APP_ID
and FACEBOOK_APP_SECRET
.Config:
/*
|--------------------------------------------------------------------------
| Application
|--------------------------------------------------------------------------
|
| The facebook ID and secret from the developer's page
|
*/
'app' => [
'id' => env('FACEBOOK_APP_ID'),
'secret' => env('FACEBOOK_APP_SECRET'),
],
/*
|--------------------------------------------------------------------------
| Registration Fields
|--------------------------------------------------------------------------
|
| The name of the fields on the user model that need to be updated,
| if null, they shall not be updated. (valid for name, first_name, last_name)
|
*/
'registration' => [
'facebook_id' => env('FACEBOOK_ID_COLUMN', 'facebook_id'),
'email' => env('EMAIL_COLUMN', 'email'),
'password' => env('PASSWORD_COLUMN', 'password'),
'first_name' => env('FIRST_NAME_COLUMN', 'first_name'),
'last_name' => env('LAST_NAME_COLUMN', 'last_name'),
'name' => env('NAME_COLUMN', 'name'),
'attach_role' => env('ATTACH_ROLE', null),
],
https://your-site.com/oauth/token
.grant_type
= facebook_login
fb_token
= {token from facebook login}
.access_token
and refresh_token
will be returned if successful.User
model has the folowing fields:facebook_id
name
or first_name
& last_name
email
password
We have found that using auto discovery can cause issues as this package relies on Laravel Passport been loaded before this package. Sometimes this doesn't happen, and caused issues as Laravel Passport sets up a singleton we reference.
We hope that one day there will be a fix to Laravel auto-discovery that will allow for dependencies to be handled better.