PHP code example of bambolee-digital / laravel-firebase-id-token
1. Go to this page and download the library: Download bambolee-digital/laravel-firebase-id-token library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bambolee-digital / laravel-firebase-id-token example snippets
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens;
protected $fillable = [
'name',
'email',
'password',
'external_id', // Add this line
];
// ...
}
return [
'credentials_base64' => env('FIREBASE_CREDENTIALS_BASE64'),
'auth_order' => env('AUTH_ORDER', 'firebase,sanctum'),
'user_model' => \App\Models\User::class,
'custom_claims' => [
// 'role' => 'user_role',
],
'auto_create_user' => true,
'default_user_data' => [
'name' => 'Dog Dot App User',
],
'sanctum' => [
'expiration' => null,
'token_name' => 'firebase-auth-token',
],
];
'guards' => [
// ...
'firebase' => [
'driver' => 'firebase',
'provider' => 'users',
],
],
Route::middleware(['auth.configurable'])->group(function () {
Route::get('/user', function () {
return Auth::user();
});
});
if (Auth::guard('firebase')->check()) {
$user = Auth::guard('firebase')->user();
// User is authenticated
}
'custom_claims' => [
'role' => 'firebase_role',
],
'sanctum' => [
'expiration' => 60 * 24, // 24 hours
'token_name' => 'firebase-auth-token',
],
bash
php artisan vendor:publish --provider="BamboleeDigital\LaravelFirebaseIdToken\Providers\FirebaseAuthServiceProvider" --tag="config"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="BamboleeDigital\LaravelFirebaseIdToken\Providers\FirebaseAuthServiceProvider" --tag="migrations"