I've and App with API. In this app, there're a route for login via API, and get a new token for use with api midddleware auth.
I've tested with Postman and work fine
{
"success": true,
"data": {
"token": "3|TSYAMjT3MOhUh8A4M8e2thOwv89jvEjoUP279z56",
"name": "Admin"
},
"message": "User signed in"
}
When try to test
function call_api_login_return_token()
{
$password = bcrypt('password'); // Also tried Hass::make('password')
$user = User::factory()->create(['password' => $password]);
$params = [
'email' => $user->email,
'password' => $password
];
$response = $this->postJson('api/login', $params, ['Accept' => 'application/json']);
$response->dump();
}
Get error Unauthorised
{#1749
+"success": false
+"message": "Unauthorised"
+"data": {#1752
+"error": "Unauthorised"
}
}
I've tried check database test (deactivate refresh) and user is correct.