在Laravel中无法使用护照获得刷新令牌

时间:2017-12-18 19:37:27

标签: php laravel laravel-5 oauth-2.0 laravel-passport

我尝试了很多东西但是现在我不可能使用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 

enter image description here 有什么帮助吗?

0 个答案:

没有答案