Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication from front end client #120

Open
tiny-village-lab opened this issue Apr 24, 2016 · 2 comments
Open

Authentication from front end client #120

tiny-village-lab opened this issue Apr 24, 2016 · 2 comments

Comments

@tiny-village-lab
Copy link

tiny-village-lab commented Apr 24, 2016

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 :)

@maksymkhar
Copy link

maksymkhar commented Apr 26, 2016

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?

@tiny-village-lab
Copy link
Author

Yes I did that too, but you also have to edit the migration file which creates the the tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants