Authentication from front end client
Hi Chris, thanks for that implementation, it works great :)
I'd like to have your opinion please :
I'm a bit new to API keys etc... so I don't know if I really get the concept. I'm doing a distant API. The server side uses Laravel and your stuff. Everything is fine.
But I'd like to develop a client to reach that API with Thorax (a framework based on Backbone). I'd like the users to connect with their email and password, get back to my client app the API Key and use that key to authenticate the user for his requests.
This is how I did this (server side) :
the route : https://gist.github.com/benoitjupille/312d720a5f62e0036ac0e75fd9f2c374
the AuthController : https://gist.github.com/benoitjupille/a6a1a8ce75f86a3255f7df5a8c1c6c1b
the Transformer : https://gist.github.com/benoitjupille/b05b8eeab4dde7901be5cd11c06b241a
What do you think about it ? Is that a good way to do this kind of stuff ? Or maybe I do not understand the way to use API keys authentication ?
Thanks a lot :)
I'm developing an API for a mobile application and I have the same question..
In the user model you've declared the relationship with the api key as follows?
public function apiKey() { return $this->hasOne('Chrisbjr\ApiGuard\Models\ApiKey'); }
Is the right way to do this?
Yes I did that too, but you also have to edit the migration file which creates the the tables.