【发布时间】:2018-01-24 00:47:53
【问题描述】:
我正在尝试在 Laravel 上创建一个基于 JWT 令牌的身份验证系统。在项目中,如果用户成功登录,我将向 API 发送登录请求并获取 Web Token。我正在为请求使用 Guzzle 包。
我搜索了很多关于它的文章,但没有一篇是有意义的。
我的控制器:
public function sigin()
{
$client = new Client();
$url = "https://localhost:8080/users/login";
$user->email = Input::get("email");
$user->password = Input::get("password");
$json_data = json_encode($user);
try{
$response = $client->request('POST',$url,[
GuzzleHttp\RequestOptions::JSON => $json_data
]);
// geting the Token in the response object. What should I do after get it
}
catch(ServerException $exception)
{
$responseBody = $exception->getResponse()->getBody(true);
}
}
【问题讨论】:
标签: php laravel client single-sign-on