mercredi 23 janvier 2019

Laravel - How to create authentication for API without database

I'm writing an app at the moment which makes use of web-sockets and therefore needs to keep track of its users somehow.

I don't really want my users to register. Before using the app they should choose a name and will get a JWT-Token for it. I don't want to save anything in a database. As these names can be non-unique I will probaply add an Id.

I'm trying to use tymon/jwt-auth": "^1.0.0-rc.3.

public function login()
{
    $token = auth()->tokenById(1234));
    return $this->respondWithToken($token);
}

For some reason the tokenById-Function seems to not be available.

Postman says: BadMethodCallException: Method Illuminate\Auth\SessionGuard::tokenById does not exist.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire