3
laravel 5.3의 새로운 oauth2 기능을 사용하여 내 laravel 프로젝트 중 하나에서 다른 API로 호출하려고합니다. 로, 내가 문제없이 호출 할 수있는 미들웨어없이'auth : api'미들웨어를 추가 한 후 경로를 찾을 수 없습니다. Laravel 5.3
Route::get('/hello', function() {
return 'hello';
})->middleware('auth:api');
:
나는이 내가 이전에서 호출 할 나의 새로운 laravel 프로젝트의 api.php 경로 파일의 경로가 미들웨어, 그것은 404 오류를 throw하지 않습니다.
$http = new GuzzleHttp\Client;
$response = $http->post('http://my-oauth-project.com/oauth/token', [
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => 'client_id',
'client_secret' => 'client_secret',
],
]);
$token = json_decode($response->getBody(), true)['access_token'];
$response = $http->get('http://my-oauth-project.com/api/hello', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$token,
],
]);
return $response->getBody();
반환되는 오류 :
이[2016-10-14 09:46:14] local.ERROR: exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: `GET http://my-oauth-project.com/api/hello` resulted in a `404 Not Found` response:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="robots" content="noindex,nofollow (truncated...)
내가 사용하는 미들웨어가 문서가 광범위하게 다루는 무언가 (클라이언트 신임 및 비밀번호 부여)를 위해 부서진다는 것은 상상할 수 없습니다. 관계없이, 이것을 찾아 주셔서 감사합니다! – samrap