Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zerossb/laravel-oauth


https://github.com/zerossb/laravel-oauth

Last synced: 8 days ago
JSON representation

Awesome Lists containing this project

README

        


Build Status
Total Downloads
Latest Stable Version
License

## About Project
An example of using oauth with laravel and passport.

## How to run the project
```bash
$ docker-compose up
```

### First steps
After running the project, run the command below to install the passport.
```bash
$ docker-compose exec server php artisan passport:install
```

Now we are going to create our key pair for the client.
```bash
$ docker-compose exec server php artisan passport:client

Which user ID should the client be assigned to?:
>

What should we name the client?:
> Laravel Client App

Where should we redirect the request after authorization? [http://localhost/auth/callback]:
> http://localhost:8001/auth/callback

New client created successfully.
Client ID:
Client secret:
```

Copy the CLIENT_ID and CLIENT_SECRET and paste it into the `.env` of the `client` application
```dosini
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=oauth_laravel_client
DB_USERNAME=oauth_laravel_client
DB_PASSWORD=oauth_laravel_client

CLIENT_ID=
CLIENT_SECRET=
REDIRECT_URL=http://localhost:8001/auth/callback
API_URL=http://localhost:8000/api/
```

And paste this in the `.env` on the `server`

```dosini
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=oauth_laravel_server
DB_USERNAME=oauth_laravel_server
DB_PASSWORD=oauth_laravel_server
```

Now open your browser and access the url [http://localhost:8001/](http://localhost:8001/) which is the client

## and good fun!