Connect with Api

Posted 3 years ago by Krlinhos

Hello!

I have two projects (Api, and an App)

From my app when the user try loggin, my method getPost call by cURL to Api, and this return a response json with a Token and object User if all was right.

object(stdClass)#291 (3) { ["status"]=> string(2) "ok" ["user"]=> object(stdClass)#292 (13) { ["_id"]=> string(1) "1" ["name"]=> string(6) "Carlos"  ["password"]=> string(60) "$2y$10$DKcfWRA5zZ1IB8wwt.7LGe055emuoml2GabwXOKSHcxaafZb.6oIi" ["rol"]=> string(5) "super" } ["token"]=> string(333) "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaXNzIjoiaHR0cDpcL1wvYXBpLmxvY2FscGxheW1vLmVzXC92MVwvYXV0aGVudGljYXRlIiwiaWF0IjoiMTQ0MzczNzAxMSIsImV4cCI6IjE0NDM3NDA2MTEiLCJuYmYiOiIxNDQzNzM3MDExIiwianRpIjoiMmEzNmFkM2E1YmZmYzFiY2RkZTQ2NmQyMmZiMWIzYjciLCJyb2wiOiJzdXBlciIsIm5hbWUiOm51bGx9.tfsq6LXHA4ekPDQmOS5Ym0CU8m5e2TFdE7reMNjfGN8" } 

But I dont know how create a session when the response was good. I try this:

Auth::login($response->user);

But not work, I recieve this error

Argument 1 passed to Illuminate\Auth\Guard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of stdClass given

Someone can help me?

Thanks!

Please sign in or create an account to participate in this conversation.