longjl1980

697 经验值

我全部都是按照你视频上做的,就是没找到缺少什么,但是用postman模拟提交,参数全部是上面的,但是是正确的,可以拿到access_token,是不是因为是本地的原因,造成guzzle的POST出问题,还是别的,请指点下。
PS:我刚才又重新开了个demo,一样的结果!我是用的laravel5.4 ,passport 3, guzzle 6.3

请教老师下
我的代码

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class OAuthController extends Controller
{
    public function oauth(Request $request){

        $http = new \GuzzleHttp\Client;
        $response = $http->post('http://various.dev/oauth/token', [
            'form_params' => [
                'grant_type' => 'authorization_code',
                'client_id' => 5,
                'client_secret' => 'bcNyfgMaB6c9oQ5JVSVFHYjGs0JyP6CFYRHi4JGm',
                'redirect_uri' => 'http://various-client.dev/callback',
                'code' => $request->code
            ],
        ]);
        return json_decode((string)$response->getBody(),true);
    }
}

如果通过浏览器操作报错

Client error: `POST http://various.dev/oauth/token` resulted in a `400 Bad Request` response:
{"error":"invalid_request","message":"The request is missing a required parameter, includes an invalid parameter value, (truncated...)

但同样的参数,如果用postman来post,结果确实正确的,请问是什么原因?

[ErrorException]
You must set the encryption key going forward to improve the security of this library - see this page for more information https://oauth2.thephpleague.com/v5-security-improvements/

请教老师,我用Passport::routes();注册路由后,为什么php artisan route:list 无法查看路由了?