library lumen-mysql-oauth
OAuth API Authorization based on Lumen Framework and MySQL
santanu/lumen-mysql-oauth
OAuth API Authorization based on Lumen Framework and MySQL
- Monday, September 18, 2017
- by santanu
- Repository
- 2 Watchers
- 0 Stars
- 3 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 1 Forks
- 1 Open issues
- 1 Versions
- 0 % Grown
OAuth Library for Lumen & MySQL
Package for creating oauthable authorization based on Lumen Framework and MySQL., (*1)
Package Installations
- Add "santanu/lumen-mysql-oauth": "*" in your lumen project, then run composer update.
- Copy all migration files from database/migrations to project's db migration directory.
- Run php artisan migrate from project's root directory.
- Add 'client_id' and 'client_secret' value in the clients collection.
- Need to copy config files from src/config to project's config directory.
- Now change User model name and path in oauth.php config file.
- Model User should be implement Santanu\Lumen_Oauth\Interfaces\Oauthable
- Add trait for model User Santanu\Lumen_Oauth\Traits\Oauthable
- Add service provider Santanu\Lumen_Oauth\Providers\ServiceProvider
- In routes/web.php add following lines for Oauth service,
$app->group(['prefix' => 'oauth'], function() use ($app)
{
$app->post('access', function() use($app) {
return $app->make('oauth.routes')->accessToken();
});
$app->post('refresh', function() use($app) {
return $app->make('oauth.routes')->refreshToken();
});
});
- In routes add 'oauth' as a middleware in service routes.
Authorization Service
- POST application-url/oauth/access
Params: grant_type(password), client_id, client_secret, username, password
Response: access_token, expires_in, token_type, scope, refresh_token
- POST application-url/oauth/refresh
Params: grant_type(refresh_token), client_id, client_secret, refresh-token
Response: access_token, expires_in, token_type, scope, refresh_token
- Send header in all API requests: Authorization: Bearer access_token
- This library is based on Lumen and MySQL if you are looking for Lumen and MongoDB package then use it From: https://github.com/santanu-brahma/lumen-mongodb-oauth
dev-master
9999999-dev
OAuth API Authorization based on Lumen Framework and MySQL
Sources
Download
MIT
The Requires
The Development Requires
by
Santanu Brahma
lumen
mysql
oauth2