这个错误是提示缺少参数,检查你的参数是否正确
可以对照这个看下
Class TokenProxy
{
protected $http;
public function __construct (Client $http)
{
$this->http = $http;
}
public function login ($email, $password)
{
if (auth()->attempt(['email' => $email, 'password' => $password])) {
return $this->proxy([
'username' => $email,
'password' => $password
]);
} else {
return response()->json([
'status' => 'error',
'message' => '请重新输入'
], 421);
}
}
public function proxy (array $data = [])
{
$data = array_merge($data, [
'grant_type' => 'password',
'client_id' => client_id,
'client_secret' => client_secret,
]);
$response = $this->http->post('http://xxx/api/oauth/token', [
'form_params' => $data
]);
$token = json_decode((string)$response->getBody(), true);
return response()->json([
'token' => $token['access_token'],
'expires_in' => $token['expires_in']
])->cookie('refreshToken', $token['refresh_token'], 864000, null, null, false, true);
}
}