Laravel Passport 500 Внутренняя ошибка сервера - PullRequest
0 голосов
/ 05 сентября 2018

, поэтому я использую Laravel с паспортом, и у меня возникли проблемы. когда я отправляю запрос на вход в AuthController @, он выдает мне 500 внутренних ошибок сервера. Вот что я работаю с

Я использую Laragon с сервером Apache и MySQL для окружающей среды. Я могу сделать запрос на мой маршрут регистрации без проблем, но мой маршрут входа не проходит. Не уверен, что мне не хватает

Это мой AuthController.php

public function login(Request $request)
{
    $http = new \GuzzleHttp\Client;

    try {
        $response = $http->post(config('services.passport.login_endpoint'), [
            'form_params' => [
                'grant_type' => 'password',
                'client_id' => config('services.passport.client_id'),
                'client_secret' => config('services.passport.client_secret'),
                'username' => $request->username,
                'password' => $request->password,
            ]
        ]);
        return $response->getBody();
    } catch (\GuzzleHttp\Exception\BadResponseException $e) {
        if ($e->getCode() === 400) {
            return response()->json('Invalid Request. Please enter a username or a password.', $e->getCode());
        } else if ($e->getCode() === 401) {
            return response()->json('Your credentials are incorrect. Please try again', $e->getCode());
        }
        return response()->json('Something went wrong on the server.', $e->getCode());
    }
}

Это моя переменная, хранящаяся в файле .env

PASSPORT_LOGIN_ENDPOINT="http://traxit-backend2.test/oauth/token"
PASSPORT_CLIENT_ID=2
PASSPORT_CLIENT_SECRET=3xlUZVF1fP5fHOQgXAY2Vd7xrIsGjGNRagcMcfU5

Это мои маршруты API

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::post('/login', 'AuthController@login');
Route::post('/register', 'AuthController@register');
Route::middleware('auth:api')->post('/logout', 'AuthController@logout');

И это журнал, который я получаю

  1. GuzzleHttp \ Exception \ RequestException -> () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php: 186
  2. GuzzleHttp \ Handler \ CurlFactory-> createRejection () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php: 149
  3. GuzzleHttp \ Handler \ CurlFactory-> finishError () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlFactory.php: 102
  4. GuzzleHttp \ Handler \ CurlFactory-> finish () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ CurlHandler.php: 43
  5. GuzzleHttp \ Handler \ CurlHandler -> __ invoke () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ Proxy.php: 28
  6. GuzzleHttp \ Handler \ Proxy-> GuzzleHttp \ Handler {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Handler \ Proxy.php: 51
  7. GuzzleHttp \ Handler \ Proxy-> GuzzleHttp \ Handler {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ PrepareBodyMiddleware.php: 66
  8. GuzzleHttp \ PrepareBodyMiddleware -> __ invoke () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Middleware.php: 30
  9. GuzzleHttp \ Middleware-> GuzzleHttp {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ RedirectMiddleware.php: 70
  10. GuzzleHttp \ RedirectMiddleware -> __ invoke () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Middleware.php: 60
  11. GuzzleHttp \ Middleware-> GuzzleHttp {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ HandlerStack.php: 67
  12. GuzzleHttp \ HandlerStack -> __ invoke () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Client.php: 277
  13. GuzzleHttp \ Client-> Transfer () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Client.php: 125
  14. GuzzleHttp \ Client-> requestAsync () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Client.php: 131
  15. GuzzleHttp \ Client-> request () C: \ laragon \ www \ traxit-backend2 \ vendor \ guzzlehttp \ guzzle \ src \ Client.php: 89
  16. GuzzleHttp \ Client -> __ call () C: \ laragon \ www \ traxit-backend2 \ app \ Http \ Controllers \ AuthController.php: 22 * ​​1048 *
  17. App \ Http \ Controllers \ AuthController-> login () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Controller.php: 54
  18. call_user_func_array () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Controller.php: 54
  19. Подсветка \ Routing \ Controller-> callAction () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Routing \ ControllerDispatcher.php: 45
  20. Подсветка \ Routing \ ControllerDispatcher-> dispatch () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Route.php: 212
  21. Подсветка \ Routing \ Route-> runController () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Route.php: 169
  22. Подсветка \ Routing \ Route-> run () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Routing \ Router.php: 679
  23. Подсветка \ Routing \ Router-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Routing \ Pipeline.php: 30
  24. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Маршрутизация \ Middleware \ SubstituteBindings.php: 41
  25. Подсветка \ Routing \ Middleware \ SubstituteBindings-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  26. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  27. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Routing \ Middleware \ ThrottleRequests.php: 57
  28. Подсветка \ Routing \ Middleware \ ThrottleRequests-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  29. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  30. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 104
  31. Подсветить \ Pipeline \ Pipeline-> then () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php: 681
  32. Подсветить \ Routing \ Router-> runRouteWithinStack () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветить \ Routing \ Router.php: 656
  33. Подсветка \ Routing \ Router-> runRoute () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Routing \ Router.php: 622
  34. Подсветка \ Routing \ Router-> dispatchToRoute () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php: 611
  35. Подсветка \ Routing \ Router-> dispatch () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Kernel.php: 176
  36. Подсветка \ Foundation \ Http \ Kernel-> Подсветка \ Foundation \ Http {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Подсветка \ Routing \ Pipeline.php: 30
  37. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ barryvdh \ laravel-cors \ src \ HandleCors.php: 36
  38. Barryvdh \ Cors \ HandleCors-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  39. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  40. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ fideloper \ proxy \ src \ TrustProxies.php: 57
  41. Fideloper \ Proxy \ TrustProxies-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  42. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  43. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest.php: 31
  44. Подсветка \ Foundation \ Http \ Middleware \ TransformsRequest-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  45. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  46. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest.php: 31
  47. Подсветка \ Foundation \ Http \ Middleware \ TransformsRequest-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  48. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  49. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ ValidatePostSize.php: 27
  50. Подсветка \ Foundation \ Http \ Middleware \ ValidatePostSize-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  51. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  52. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode.php: 62
  53. Подсветка \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode-> handle () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 151
  54. Подсветка \ Pipeline \ Pipeline-> Подсветка \ Pipeline {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php: 53
  55. Подсветка \ Routing \ Pipeline-> Подсветка \ Routing {closure} () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php: 104
  56. Подсветка \ Pipeline \ Pipeline-> then () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Kernel.php: 151
  57. Подсветка \ Foundation \ Http \ Kernel-> sendRequestThroughRouter () C: \ laragon \ www \ traxit-backend2 \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Kernel.php: 116
  58. Подсветка \ Foundation \ Http \ Kernel-> handle () C: \ laragon \ www \ traxit-backend2 \ public \ index.php: 55

1 Ответ

0 голосов
/ 21 мая 2019

Проблема была в том, что services.passport в моем services файле конфигурации не существовало. Я положил это в мой services.php файл конфигурации.

'passport' => [
        'login_endpoint'  => env('TOKEN_LOGIN_ENDPOINT'),
        'client_id'    => env('TOKEN_CLIENT_ID'),
        'client_secret' => env('TOKEN_CLIENT_SECRET'),
    ],
...