Laravel passport 获取 token 时无响应?
$this->validate($request, [
'name' => 'required|string',
'password' => 'required|string',
]);
$name = $request->input('name');
$password = $request->input('password');
$user = User::where('name',$name)->first();
if ($user->type == 0 ){
$scope = 'student';
}elseif ($user->type == 1){
$scope = 'stuff';
}elseif ($user->type ==2){
$scope = 'company';
}else{
$scope = '';
}
$http = new Client();
$response = $http->post(url()->previous().'/oauth/token',
[
'form_params'=> [
'grant_type' => 'password',
'client_id' =>env('CLIENT_ID'),
'client_secret'=>env('CLIENT_SECRET'),
'username'=>$name,
'password'=>$password,
'scope'=> $scope,
],
]);
$datas = json_decode((string)$response->getBody()->getContents(),true);
$datas['client_type'] = '2';
return $this->build_response($datas);
每次都卡在获取$response处,也不报错
推荐文章: