相关疑难解决方法(0)

Laravel 5.3:护照实施-{“错误”:“ invalid_client”,“消息”:“客户端身份验证失败”}

我遵循了Laracast中提到的确切步骤:Laravel 5.3中的新增功能:Laravel Passportapi authentication使用实现oauth2

web.php在客户/消费者项目中的文件如下所示:

use Illuminate\Http\Request;


Route::get('/', function () {
$query = http_build_query([
     'client_id' => 2,
     'redirect_uri' => 'http://offline.xyz.com/callback',
     'response_type' => 'code',
     'scope' => '',
    ]);

return redirect ('http://api.xyz.com/oauth/authorize?'.$query);
});

Route::get('/callback', function (Request $request){
$http= new GuzzleHttp\Client;

$response = $http->post('http://api.xyz.com/oauth/token',[
    'form_params' => [
            'grant_type' => 'authorization_code',
            'client_id' => 2 , 
            'client_secret' => 'tUGYrNeWCGAQt220n88CGoXVu7TRDyZ20fxAlFcL' ,
            'redirect_uri' => 'http://offline.xyz.com/callback',
            'code' => $request->code,
        ],
    ]);

return json_decode((string) $response->getBody(), true);
});
Run Code Online (Sandbox Code Playgroud)

我正在获得权限请求页面,我需要在该页面上authorize允许我的客户端访问api。但是,一旦单击授权,我将被重定向到显示以下消息的页面: …

php oauth-2.0 laravel-5.3 laravel-passport

6
推荐指数
1
解决办法
7351
查看次数

标签 统计

laravel-5.3 ×1

laravel-passport ×1

oauth-2.0 ×1

php ×1