Building Bagisto Android Application
I think this is my first piece here, so bare with me.
Where do I start? Oh yeah! The official documentation suck if you are trying to build a meaningful android application powered by Bagisto. I will get to that later in the future.
To future me, do the following for jwt to work:
php artisan jwt:secret
php artisan cache:clear
php artisan config:clear
On the config/app.php, ensure that this line is there under providers:
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,Then under aliases have:
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::classIn the app/Http/Kernel.php under $routeMiddleware ensure you have:
'auth.jwt' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class,
'auth-renew.jwt' => \Tymon\JWTAuth\Http\Middleware\AuthenticateAndRenew::class,
'jwt.refresh' => \Tymon\JWTAuth\Http\Middleware\RefreshToken::class,Next, hunt the API package from the routes you want protected by the api middleware and add the middleware on the group:
Route::middleware(['api'])->prefix('checkout')->group(function ($router) {You know what? You really don’t need all that. The default setting for Bagisto just work. There is no need of Authorization API header at all.
Get Raphael Ndwigah’s stories in your inbox
Join Medium for free to get updates from this writer.
All you need is during the login process have your API endpoint as such:
https://{your-domain}/api/customer/login?token=trueSave the API token.
For other request that require the users to be authenticated just include the token as part of the request body… Like this:
cartItem.put("token",sharedPref.getCustomerApiToken());That’s all folk.





