I'm working on a project where I need to develop an api to be consumed for websites developed with Laravel, to this api I'm using Porto-SAP/Hello-API. I'm trying to make login into my api.app.local from a Laravel website in dev.local but I always get this response:
""message":"Credentials Incorrect.","status_code":401"
However if I make the same call from a plain php file using curl_init function I can make login without problems, in dev.local (websites) I have tried with curl_init function and using ixudra/curl library the answer always is the same "Credentials Incorrect", in the debug message i can read this ">run('churromorales20...', 'Ch4p4rr1t0')"** confirming that credentials are correct.
I tried so hard to make a debug to find the problem but I got stuck, I don't know if I'm making a big mistake. Even I have tried with Postman tool with same credentials and I can login without problems.
This is my code in Laravel project (websites)
$response = Curl::to($urlapi)
->withData( array( 'email' => 'churromorales20@gmail.com', 'password' => 'Ch4p4rr1t0**' ) )
->post();
This is the response I got from api.app.local (Porto-SAP Hello-API installation)
{"message":"Credentials Incorrect.","status_code":401,"debug":{"line":52,"file":"C:\\xampp\\htdocs\\ultra-api\\app\\Containers\\Authentication\\Tasks\\ApiLoginWithCredentialsTask.php","class":"App\\Containers\\Authentication\\Exceptions\\AuthenticationFailedException","trace":["#0 C:\\xampp\\htdocs\\ultra-api\\app\\Containers\\Authentication\\Actions\\ApiUserLoginAction.php(46): App\\Containers\\Authentication\\Tasks\\ApiLoginWithCredentialsTask-**>run('churromorales20...', 'Ch4p4rr1t0**')"**,"#1 C:\\xampp\\htdocs\\ultra-api\\app\\Containers\\Authentication\\UI\\API\\Controllers\\Controller.php(28): App\\Containers\\Authentication\\Actions\\ApiUserLoginAction->run('churromorales20...', 'Ch4p4rr1t0**')","#2 [internal function]: App\\Containers\\Authentication\\UI\\API\\Controllers\\Controller->userLogin(Object(App\\Containers\\Authentication\\UI\\API\\Requests\\UserLoginRequest), Object(App\\Containers\\Authentication\\Actions\\ApiUserLoginAction))","#3 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(55): call_user_func_array(Array, Array)","#4 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(44): Illuminate\\Routing\\Controller->callAction('userLogin', Array)","#5 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(203): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Containers\\Authentication\\UI\\API\\Controllers\\Controller), 'userLogin')","#6 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(160): Illuminate\\Routing\\Route->runController()","#7 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(559): Illuminate\\Routing\\Route->run()","#8 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))","#9 C:\\xampp\\htdocs\\ultra-api\\app\\Containers\\Localization\\Middlewares\\LocalizationMiddleware.php(34): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))","#10 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): App\\Containers\\Localization\\Middlewares\\LocalizationMiddleware->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#11 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#12 C:\\xampp\\htdocs\\ultra-api\\vendor\\dingo\\api\\src\\Http\\Middleware\\PrepareController.php(45): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))","#13 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Dingo\\Api\\Http\\Middleware\\PrepareController->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#14 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#15 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))","#16 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(561): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#17 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(520): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Dingo\\Api\\Http\\Request))","#18 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(498): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))","#19 C:\\xampp\\htdocs\\ultra-api\\vendor\\dingo\\api\\src\\Routing\\Adapter\\Laravel.php(81): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#20 C:\\xampp\\htdocs\\ultra-api\\vendor\\dingo\\api\\src\\Routing\\Router.php(513): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')","#21 C:\\xampp\\htdocs\\ultra-api\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#22 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(114): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))","#23 C:\\xampp\\htdocs\\ultra-api\\vendor\\barryvdh\\laravel-cors\\src\\HandleCors.php(34): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#24 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Barryvdh\\Cors\\HandleCors->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#25 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#26 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#27 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#28 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#29 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#30 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#31 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(46): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#32 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#33 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#34 C:\\xampp\\htdocs\\ultra-api\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#35 C:\\xampp\\htdocs\\ultra-api\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))","#36 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#37 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))","#38 C:\\xampp\\htdocs\\ultra-api\\app\\Containers\\Debugger\\Middlewares\\RequestsMonitorMiddleware.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))","#39 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): App\\Containers\\Debugger\\Middlewares\\RequestsMonitorMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))","#40 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))","#41 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))","#42 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(149): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#43 C:\\xampp\\htdocs\\ultra-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))","#44 C:\\xampp\\htdocs\\ultra-api\\public\\index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))","#45 {main}"]}}
via Cecilio Morales