Laravel Passport Auth 在同一项目中的自服务器和客户端上运行时卡住,以进行基于密码的令牌身份验证
登录控制器
public function authenticaterrr(Request $request)
{
$http = new Client();
try{
//dd("Hello");
$response = $http->post(url('oauth/token'), [
'form_params' => [
'grant_type' => 'password',
'client_id' => '2',
'client_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
// 'username' => $request->get('username'),
// 'password' => $request->get('password'),
'username' => '[email protected] /cdn-cgi/l/email-protection',
'password' => 'xxxxx',
'scope' => '*',
],
]);
// $apiResponse = json_decode((string) $response->getBody(), true);
// dd($apiResponse);
$apiResponse = json_decode((string) $response->getBody(), true);
dd($apiResponse);
session(['api'=> $apiResponse]);
session(['api-token'=> $apiResponse['access_token']]);
return json_decode($response->getBody(), true);
}catch (ClientException $exception){
dd("Hello");
return json_decode($exception->getResponse()->getBody(), true);
}
}
在Web.php中
Route::get('/auth/api/validate', 'Auth\LoginController@authenticaterrr');
在 PostMan 中它没有被卡住这是输出 https://i.stack.imgur.com/KlOSJ.png
如果我将创建新项目并使用它,那么它将对我有用,那么在同一个项目中运行的解决方案是什么