PHP code example of digram / bukua-auth
1. Go to this page and download the library: Download digram/bukua-auth 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/ */
digram / bukua-auth example snippets
protected $fillable = [
...
'bukua_user_id',
'bukua_access_token',
'bukua_refresh_token',
'name',
];
Schema::table('users', function ($table) {
...
$table->char('bukua_user_id', 36)->nullable();
$table->text('bukua_access_token')->nullable();
$table->text('bukua_refresh_token')->nullable();
$table->string('name')->nullable();
});
// In your EventServiceProvider.php
protected $listen = [
\BukuaAuth\Events\BukuaUserLoggedInEvent::class => [
\App\Listeners\HandleBukuaUserLoggedIn::class, // Your listener
],
];
// \App\Listeners\HandleBukuaUserLoggedIn
class HandleBukuaUserLoggedIn
{
/**
* Handle the event.
*
* @param \BukuaAuth\Events\BukuaUserLoggedInEvent $event
* @return void
*/
public function handle(BukuaUserLoggedInEvent $event)
{
// Access the user from the event
$user = $event->user;
// Write in laravel log
\Log::info("Bukua user logged in: {$user->uid}", [
'user_uid' => $user->uid,
'email' => $user->email,
'timestamp' => now(),
]);
}
}
bash
php artisan migrate
bash
php artisan cache:clear
html
<!-- Login with Bukua Button -->
@if (Route::has('bukua-auth.authorize'))
<form action="{{ route('bukua-auth.authorize') }}" method="POST">
@csrf
<button type="submit" class="btn btn-primary">
Login with Bukua
</button>
</form>
@endif