logout user with bearer token laravel code example
Example 1: laravel token logout
public function logout (Request $request) {
$accessToken = auth()->user()->token();
$token= $request->user()->tokens->find($accessToken);
$token->revoke();
return response(['message' => 'You have been successfully logged out.'], 200);
}
Example 2: laravel get authorization bearer token
//get Authorization Bearer Token value
$token = $request->bearerToken();