Posts

Showing posts with the label Authentication

Google authentication with Laravel

Image
Google authentication with Laravel First create a Laravel project           composer create-project --prefer-dist laravel/laravel googleLogin Now we have to install Jetstream           composer require laravel/jetstream Now we have to create the authentication. For this you can create basic login, registration and email verification           php artisan jetstream:install livewire Now install the node.js package          npm install Then run          npm run dev Create a database and migrate the tables          php artisan migrate Now, we will install Socialite Package that provide api to connect with google account           composer require laravel/socialite Now you have to create Google App in Google Developer Console First create an app in OAuth Consent Screen Then go to Credentials and clic...

Laravel API With Sanctum

Image
  Laravel API With Sanctum Install a Laravel project           composer create-project laravel/laravel [my-project-name] Install the package           Composer require laravel/sanctum Do the migration           php artisan vendor:publish --provider=”Laravel\Sanctum\SanctumServiceProvider”  php artisan migrate Replace the kernel.php -> middlewareGroups -> api 'api' => [     \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,     'throttle:api',     \Illuminate\Routing\Middleware\SubstituteBindings::class, ], Add this to User model           use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable;} Add this to api.php routes           Route::group(['middleware' => ['auth:sanctum']], function () { Route::get('/emp...

Laravel API With JWT Authentication

Image
Laravel API With JWT Authentication   Create a new Laravel project        composer create-project laravel/laravel [my-project-name] Install JWT auth          composer require tymon/jwt-auth Go to the app->Models->User.php and update that user model         <?php           namespace App ;           use Tymon \ JWTAuth \ Contracts \ JWTSubject ;           use Illuminate \ Notifications \ Notifiable ;           use Illuminate \ Foundation \ Auth \ User as Authenticatable ;             class User extends Authenticatable implements JWTSubject           {               use Notifiable ;               // Res...