我想要一些关于如何在JSON中使用POST和格式化结果(最好使用Laravel)来制作PHP API的建议。API需要使用这些参数(邮箱地址、密码、令牌)来验证用户凭证。
回复200:
{
"data": [
{
"id": 1,
"email_address": test@gmail.com,
"authenticated": true,
"type": password,
"timestamp": 436543678572,
"last_login": 436543678572,
"session_expires": 436543678572
},
],
}使用SSO的响应200:
{
"data": [
{
"id": 1,
"email_address": test@gmail.com,
"authenticated": true,
"type": sso,
"timestamp": 436543678572,
"last_login": 436543678572,
"session_expires": 436543678572
},
],
}发布于 2018-04-28 12:06:16
你可以很容易地使用https://jwt.io (laravel库:https://github.com/tymondesigns/jwt-auth),将你想要的响应信息放在你的用户模型的getJWTCustomClaims上
public function getJWTCustomClaims()
{
return [
'user' => [
'id' => $this->id,
'name' => $this->user_name,
]
];
}而且,在前端层中的任何地方,您都可以从令牌有效负载中检索信息。
https://stackoverflow.com/questions/50071858
复制相似问题