This project is an example of how to implement multi-authentication in a Laravel application using Passport.
- Clone this repository:
git clone https://github.com/michaelnabil230/multi-auth-laravel-passport.git
- Install dependencies:
cd multi-auth-laravel-passport
git clone --single-branch --branch fix/provider-token-creation https://github.com/michaelnabil230/passport
composer install
- Generate the application key:
php artisan key:generate
- Migrate the database:
php artisan migrate
- Install Passport:
php artisan passport:keys
php artisan passport:client --personal --provider=users
php artisan passport:client --personal --provider=admins
- Seed the database:
php artisan db:seed
- Start the development server:
php artisan serve
This project includes two types of authentication: user
and admin
.
To authenticate as a user, use the credentials:
- Email:
[email protected]
- Password:
password
This will return an access token that you can use to authenticate future requests.
To authenticate as an admin, use the credentials:
- Email:
[email protected]
- Password:
password
This will return an access token that you can use to authenticate future requests.
You can test the API endpoints using Postman. To do so, you will need to import the Postman collection and set up the environment variables.
- Open Postman and click on the
Import
button in the top left corner. - In the
Import
dialog, and drop the file. - Click on the
Import
button to import the collection.
- In Postman, click on the gear icon in the top right corner to open the
Manage Environments
dialog. - Click on the
Add
button to create a new environment. - Enter a name for the environment (e.g.
Multi-Auth Laravel Passport
) and add the following variables:
adminAccessToken
userAccessToken
- Click on the
Add
button to save the environment.
- Select the
Multi-Auth Laravel Passport
environment from the dropdown menu in the top right corner. - Use the API endpoints in the Postman collection to test the application. You can use the environment variables to fill in the required values.