@aronaman having a shared access token is fine. I would pass it in in the headers rather than as part of the url though.
I'm using a static access_token for my api due to it only needing to be accessible by a vue front end. You would want to do something similar to my middleware to check it.
namespace App\Http\Middleware;
use Closure;
class VerifyAPIAccess
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (
!($_ENV['APP_ENV'] === 'local')
&& (
!$request->header('access-token')
|| $request->header('access-token') !== env('APP_API_TOKEN')
)
) {
return response()->json(['Message' => 'You do not access to this api.'], 403);
}
return $next($request);
}
}
and then add it to your group in your api.php
Route::group([
'prefix' => 'v1',
'as' => 'v1.',
'middleware' => [
VerifyAPIAccess::class
]
], function () {
// protected api routes accessible by api/vi/yourRoute
});
if you are only accessing the Laravel app from your local desktop app, you could additional limit access based on IP address range.