tokens()?->first(); if ($token === null) { $token = Auth::user()->createToken('api-token', ['update-screen']); } $this->token = $token->plainTextToken; $this->devices = auth()->user()->devices?->pluck('id', 'name'); $this->selected_device = $this->devices->first(); } public function regenerateToken() { Auth::user()->tokens()?->first()?->delete(); $token = Auth::user()->createToken('api-token', ['update-screen']); $this->token = $token->plainTextToken; } }; ?>

API Plugin

@if(isset($devices)) @foreach($devices as $id => $name) {{ $id }} @endforeach @endif

POST {{ route('display.update') }}?device_id={{ $selected_device }}

Headers

Authorization Bearer {{$token ?? '**********'}} Regenerate Token

Body

{"markup":"<h1>Hello World</h1>"}
                    

GET {{ route('display.status') }}?device_id={{ $selected_device }}

Headers

Authorization Bearer {{$token ?? '**********'}} Regenerate Token