我尝试了很多东西但是现在我不可能使用api路由获取刷新令牌。这是我的代码。在API.php中
<?php
use Illuminate\Http\Request;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Laravel\Passport\Http\Controllers\AccessTokenController;
Route::post('connect', function (Request $request) {
$http = new GuzzleHttp\Client;
$response = $http->post('http://127.0.0.1:8000/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => $request->client_id,
'client_secret' => $request->client_secret,
'username' => $request->username,
'password' => $request->password,
'scope' => ''
],
]);
return json_decode((string) $response->getBody(), true);
});
它总是返回相同的错误:
Error creating resource: [message] fopen(http://127.0.0.1:8000/oauth/token): failed to open stream: HTTP request failed! [file] /var/www/html/passport_test_3/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php