生成登录令牌时出现Swagger UI错误

时间:2019-10-21 05:47:01

标签: api swagger-ui laravel-6

大胆地测试API时,我在用户登录中遇到错误

email: info@vibhaa.in
password: password

在生成登录令牌时遇到问题。

我的代码:

public function login(Request $request)
{

    $credentials = request(['email', 'password']);
    if(!Auth::attempt($credentials))
        return response()->json([
            'message' => 'Unauthorized'
        ], 401);
        $user = $request->user();
        $request->request->add([
            'username' => $request->email,
            'grant_type' => 'password',
            'client_id' => env('PASSWORD_CLIENT_ID'),
            'client_secret' => env('PASSWORD_CLIENT_SECRET'),
            'scope' => '',
        ]);
        // forward the request to the oauth token request endpoint and Return Token
        $res = Route::dispatch(request()->create('oauth/token', 'POST', $this->loginCredentials($request)));
        $this->api_response = json_decode($res->getContent());
        return response()->json([
            'token' => $this->api_response,
            'usersDetail' =>  $user
        ], 200);
    }
}

回复: 卷曲:

curl -X POST "http://localhost/minidmsapi/api/auth/login?email=info%40vibhaa.in&password=password" -H "accept: application/json" -H "X-CSRF-TOKEN: "

请求网址:

http://localhost/minidmsapi/api/auth/login?email=info%40vibhaa.in&password=password

响应正文:


"token": {
    "error": "invalid_request",
    "error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
    "hint": "Check the `password` parameter",
    "message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}

0 个答案:

没有答案