При тестировании API с помощью swagger, я получаю сообщение об ошибке при входе в систему.
email: info@vibhaa.in
password: password
При создании токена для входа возникает проблема.
Мой код:
public function login(Request $request)
{
$credentials = request(['email', 'password']);
if(!Auth::attempt($credentials))
return response()->json([
'message' => 'Unauthorized'
], 401);
$user = $request->user();
$request->request->add([
'username' => $request->email,
'grant_type' => 'password',
'client_id' => env('PASSWORD_CLIENT_ID'),
'client_secret' => env('PASSWORD_CLIENT_SECRET'),
'scope' => '',
]);
// forward the request to the oauth token request endpoint and Return Token
$res = Route::dispatch(request()->create('oauth/token', 'POST', $this->loginCredentials($request)));
$this->api_response = json_decode($res->getContent());
return response()->json([
'token' => $this->api_response,
'usersDetail' => $user
], 200);
}
}
Ответ: Curl:
curl -X POST "http://localhost/minidmsapi/api/auth/login?email=info%40vibhaa.in&password=password" -H "accept: application/json" -H "X-CSRF-TOKEN: "
Запрос URL:
http://localhost/minidmsapi/api/auth/login?email=info%40vibhaa.in&password=password
Тело ответа:
"token": {
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Check the `password` parameter",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}