I have a laravel application that I have recently installed laravel passport with. This application makes a series of internal api calls to retrieve data. With laravel passport whenever I make these internal api calls it gives back an unauthenticated error message.
I have added the 'auth:api' middleware to my api routes and want to be able to access them internally. Do I need to send a bearer token with the request to allow the request through. Also how would I generate this token?
Here is an example of the code with call to make internal api calls.
public function postToApi($url, $data) {
$req = Request::create($url, 'POST', $data);
try {
$res = app()->handle($req);
} catch (Exception $e) {
return "not found";
}
}
Here is an example of how the routes look
Route::group(['middleware' => 'auth:api', 'prefix' => 'api', 'namespace' => 'Modules\Forum\Http\Controllers'], function(){
Route::get('reply/{id}', 'ReplyApiController@show' );
Route::get('thread/{id}', 'ThreadApiController@show' );});