PHPackages                             wcaaan/firebase-token-authentication - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. wcaaan/firebase-token-authentication

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

wcaaan/firebase-token-authentication
====================================

Firebase token authentication driver for Laravel

v3.1.1(4y ago)054MITPHPPHP ^7.4|^8.0

Since Sep 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/wcaaan/firebase-token-authentication)[ Packagist](https://packagist.org/packages/wcaaan/firebase-token-authentication)[ Docs](https://github.com/wcaaan/firebase-token-authentication)[ RSS](/packages/wcaaan-firebase-token-authentication/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (0)

Firebase Token Authentication for Laravel
=========================================

[](#firebase-token-authentication-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9642ad7855d45f35ef16922c1330cc0df9e6cc4bde45986a270261f3847944b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77636161616e2f66697265626173652d746f6b656e2d61757468656e7469636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wcaaan/firebase-token-authentication)[![Total Downloads](https://camo.githubusercontent.com/026a8d6edec5721902be98092c4204c446a222084f3d995fd058346867c4eab9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77636161616e2f66697265626173652d746f6b656e2d61757468656e7469636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wcaaan/firebase-token-authentication)

The driver contains a firebase guard that authenticates user by Firebase Authentication JWT token. To login use [Firebase Authentication](https://firebase.google.com/docs/auth/web/firebaseui).

Compatibility &amp; Requirement
-------------------------------

[](#compatibility--requirement)

The package is tested with `php >= 7.4``Laravel 7.3``lcobucci/jwt 4.0`

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require wcaaan/firebase-token-authentication
```

### Update `config/auth.php`.

[](#update-configauthphp)

```
'guards' => [
    'web' => [
        'driver' => 'firebase',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'firebase',
        'provider' => 'users',
    ],
],

```

Configuration
-------------

[](#configuration)

```
php artisan vendor:publish --provider="Wcaaan\FirebaseTokenAuthentication\FirebaseTokenAuthenticationServiceProvider" --tag="config"
```

```
return [
    /*
     * The firebase_project_id key is used when connecting to firebase authentication.
     */
    'firebase_project_id' => '',
    /*
     * The target_provider key is used for connecting with your desired model.
     * by default laravel provider is users
     * If target_provider is not set, by defalt users will be used.
     * Example: In below example your target_provider is users
     *
     * 'providers' => [
     *		'users' => [
     *			'driver' => 'eloquent',
     *			'model' => App\User::class,
     *		],
     *	],
     *
     */
    'target_provider' => 'users',
];
```

Implementation
--------------

[](#implementation)

### Update `User` model

[](#update-user-model)

Update your authentication model. Generally it is `User`

`use Wcaaan\FirebaseTokenAuthentication\FirebaseTokenAuthenticable`

`public $incrementing = false;`

`protected $fillable = [ 'name', 'email', 'phone', 'image' ];`

Eloquent example:

```
