Laravel 护照 oauth/authorize 错误

Laravel passport oauth/authorize error

我正在尝试通过 oauth/authorize 使用 Passport 以允许 Web 应用程序稍后获取代码和请求令牌,但我收到错误

Route [login] not defined

下面是我的代码。

客户代码

    // 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'];
});

也许你有不止一个错误。看起来您忘记定义通用身份验证路由。从 php artisan make:authAuth::routes() 开始。 OAuth 路由没有 login 路由,你得到的错误说你没有定义 login 路由。实际上是在Auth::routes()中定义的。

我有同样的问题,显然,我没有通过请求中的接受 header

Accept:application/json