Ошибка паспорта Laravel / авторизация

Я пытаюсь использовать Passport, используя oauth / authorize, чтобы позволить веб-приложению получить код и запросить токен позже, но я получаю ошибку

Маршрут [логин] не определен

Ниже мой код.

Код клиента

    // First route that user visits on consumer app
Route::get('/', function () {
// Build the query parameter string to pass auth information to our request
$query = http_build_query([
'client_id' => 3,
//'client_secret' => 'MtkEmBL0f0Bf4LcEPcOBUS0wLHvF5xqqchhCpaTH',
'redirect_uri' => 'http://client.app:8082/callback',
'response_type' => 'code',
'scope' => ''
]);

// Redirect the user to the OAuth authorization page
return redirect('http://server.app:8082/oauth/authorize?' . $query);
});// Route that user is forwarded back to after approving on server
Route::get('/callback', function (Request $request) {
return 'test 2';
$http = new GuzzleHttp\Client;

$response = $http->post('http://server.app:8082/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => 3, // from admin panel above
'client_secret' => 'MtkEmBL0f0Bf4LcEPcOBUS0wLHvF5xqqchhCpaTH', // from admin panel above
'redirect_uri' => 'http://client.app:8082/callback',
'code' => $request->code // Get code from the callback
]
]);

// echo the access token; normally we would save this in the DB
return json_decode((string) $response->getBody(), true)['access_token'];
});

Ошибка запроса oauth / authorize

Ошибка запроса oauth / authorize

1

Решение

Может быть, у вас есть более одной ошибки. Похоже, вы забыли определить общие маршруты авторизации. Начать с php artisan make:auth или же Auth::routes(), OAuth маршруты не имеют login маршрут, ошибка, которую вы получили, говорит, что вы не определили login маршрут. Определяется в Auth::routes() на самом деле.

2

Другие решения

У меня была та же проблема, по-видимому, я не передавал заголовок Accept в запросе

Accept:application/json
0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector