So here is the flow:
- User login in 'Login' page,
- User input phone number and password,
- Request to API -> If 'Success', save data to Database,
- User Logged in.
I try to find some references but i still couldn't understand it.
Here is my Controller:
public function getAPI(){
$client = new Client;
$response = $client->post('http://example.com/api/login', [
'form-data' => [
'login' => '0xxxxxxx',
'password' => 'dxxxxxxxx'
]
]);
dd($response);
}
And when i try to check if it got an success response or not, here is the result:
Client error: `POST http://example/api/login` resulted in a `401 Unauthorized` response: {"error":"invalid_credentials"}
Yes, it might be because of the invalid input but i check it via Postman and that's works just fine.
Here is the response:
{
"success": true,
"token": "eyJ0eXAiOiJKV1QiasdasdqweqfdsJ9.eyJzdWIiOjEwMCwiaXNzIjoiaHR0cDovL2Rldi50b2tvaGFqaS5jby5pZC9hcGkvbG9naW4iLCJpYXQiOjE1OTExOTasdwqeqweqwewqeMDM3OCwibmJmIjoxNTkxMTkwNzc4LCJqdGkiOiJoVEFEWExBYmMzUlR2elVQIn0.kaRaNgrfoboJiazLLO01V_1Gtgh7LJx0k4o918ZhYik"
}
So that's all, could you give me some suggestion to how to handle it?
Thank you.