gpt4 book ai didi

JWT authentication with Laravel & Vuejs(基于Laravel&Vuejs的JWT认证)

转载 作者:bug小助手 更新时间:2023-10-28 20:51:58 25 4
gpt4 key购买 nike



I'm working with JWT authentication using Laravel 6 and vue.js 2, and jwt package: tymon/jwt-auth. I'm testing my api using postman. But it returns "1" instead access_token. Could anyone please help me with it? Following is api method:

我正在使用Laravel 6和vue.js 2以及JWT包Tymon/jwt-auth进行JWT身份验证。我正在使用邮递员测试我的API。但它返回“1”,而不是ACCESS_TOKEN。有谁能帮我搬一下吗?接口方法如下:


public function loginMe(Request $request)
{

$credentials = $request->only('email', 'password');

try {
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json([
'success' => false,
'message' => 'Login credentials are invalid.',
], 400);
}
} catch (JWTException $e) {
return response()->json([
'success' => false,
'message' => 'Could not create token.',
], 500);
}
return response()->json([
'success' => true,
'access_token' => $token,
]);
}

更多回答
优秀答案推荐

Often the problem is on header.

问题往往出在标题上。


Try to add in the Postman request, in the header:

尝试在标题中添加邮递员请求:



  • Content-Type: application/x-www-form-urlencoded

  • Accept: application/json


更多回答

Already that's given but no luck.

这已经被给予了,但没有运气。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com