Аутентификация Laravel Rest при отправке через HttpClient Android

Как я могу отфильтровать приложение для отдыха laravel, только аутентифицированный идентификатор пользователя и правильный пароль при отправке через андроид HttpClient? Я пытаюсь найти лучший способ, но не получаю лучшего образца.

Это мой код:

public static int LogExceptionError(final ExceptionLog exceptionLog) { final HttpResponse[] response = new HttpResponse[1]; new Thread(new Runnable() { public void run() { // Create a new HttpClient and Post Header HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(AndroidHelperUtility.getBaseUrl("exceptionlog/create", AndroidHelperUtility.IS_DEBUG_MODE)); try { Gson gson = new Gson(); String jsonString = gson.toJson(exceptionLog); JSONObject jsonObject = new JSONObject(); jsonObject = new JSONObject(jsonString); JSONArray jsonArray = new JSONArray(); jsonArray.put(jsonObject); // Post the data: httpPost.setHeader("json", jsonObject.toString()); httpPost.getParams().setParameter("jsonpost", jsonArray); // Execute HTTP Post Request System.out.print(jsonObject); HttpResponse httpResponseponse = httpClient.execute(httpPost); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }).start(); if (response[0] != null) { return 1; } else { return 0; } } 

Контроллер Laravel:

 public function postCreate() { $json = $_SERVER['HTTP_JSON']; $data = json_decode($json); $object = ExceptionLogService::create($data); return Response::json($object); } 

Класс обслуживания:

 class ExceptionLogService extends BaseService { public static function create($data) { $object = array( "refNumber" => $data->refNumber, "source" => $data->source, "userName" => $data->userName, "description" => $data->description ); ExceptionLogRepository::create($object); return $object; } 

Related of "Аутентификация Laravel Rest при отправке через HttpClient Android"