Код: Выделить всё
public function login(LoginRequest $request)
{
$customer = Customer::where('username', $request->username)->first();
$oClient = OClient::where('password_client', 1)->first();
if (!$oClient) {
return response()->json([
'status' => 'failed',
'message' => 'OAuth client not found',
'code' => 400
], 400);
}
$response = Http::asForm()->post('http://localhost:8000/oauth/token', [
'grant_type' => 'password',
'client_id' => $oClient->id,
'client_secret' => $oClient->secret,
'username' => $request->username,
'password' => $request->password,
'provider' => 'customers',
'scope' => '*',
]);
if ($response->successful()) {
$tokens = $response->json();
return response()->json([
'access_token' => $tokens['access_token'],
'refresh_token' => $tokens['refresh_token'],
]);
} else {
return response()->json([
'status' => 'failed',
'message' => $response->json('error_description', 'Unknown error'),
'code' => $response->status(),
], $response->status());
}
}
{ "status": "failed", "message": "Ошибка cURL 28: время ожидания операции истекло через 30016 миллисекунд, получено 0 байтов (см. https:/ /curl.haxx.se/libcurl/c/libcurl-errors.html) для http://localhost:8000/oauth/token", "code": 400
Подробнее здесь: https://stackoverflow.com/questions/790 ... th-0-bytes