Am using laravel with android and whenever a 401 error is triggered in laravel i would like to attach to the 401 error a custom header
WWW-Authenticate: xBasic realm=32334
Whenever a 401 response is returned to android i get
com.android.volley.NoConnectionError: java.io.IOException: No authentication challenges found
So after aresearch i found out the problem is due to the fact that i need to add a header to the response given i laravel
So am using the default passport oauth/token route which routes are set in authservice provider like
public function boot()
{
$this->registerPolicies();
Route::group(['middleware'=>'appconnection'], function(){
Passport::routes();
});
}
As from above ive added an appconnection middleware to passport routes now i want to handle the response to check if 401 is ever returned and add the custom header
so in my middleware am stuck at adding the header
class AppConnectionMiddleware
{
public function handle($request, Closure $next)
{
$returned = $next($request);
//check if $returned has a 401 status response
//am stuck here
}
}
So how do i manipulate the response to include the custom response header