我创建了一个新的 laravel 5.3 项目并根据本教程进行设置:https://mattstauffer.co/blog/introducing-laravel-passport
但是当我尝试通过从 Firefox 中的 http 请求插件发送安静的请求来检查 oauth 服务器时,我得到 Not Found - 404
我的请求网址:http://localhost/pcheck/user
并且我已经设置了标题:"Application/json"
我的 web.php 路由文件:
// First route that user visits on consumer app Route::get('/redirect', function () { // Build the query parameter string to pass auth information to our request $query = http_build_query([ 'client_id' => 3, 'redirect_uri' => 'http://localhost/pcheck/callback', 'response_type' => 'code', 'scope' => 'conference' ]);
// Redirect the user to the OAuth authorization page
return redirect('http://localhost/pcheck/oauth/authorize?' . $query);
});
// Route that user is forwarded back to after approving on server Route::get('/callback', function (Request $request) { $http = new GuzzleHttp\Client;
$response = $http->post('http://localhost/pcheck/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => '3',
'client_secret' => 'azWM7CGS4UtIQ30sd5bwW5s53P52QjaRmUdWjKpx',
'redirect_uri' => 'http://localhost/pcheck/callback',
'code' => $request->code,
],
]);
return json_decode((string) $response->getBody(), true);
});
我的 api.php 路由文件:
Route::get('/user', function (Request $request) { return $request->user(); })->middleware('auth:api');
我不知道我错在哪里任何想法?