In my website a user can login in 3 ways
- Pass the email & password
- Login with Google and Facebook
- Login with IOT device(with the device id)
Now I am confused on how to authenticate a user. For the first option I can use the JWT token but I have no idea on how to authenticate the Google and IOT devices.
Note: My API is in Lumen. Any guidance would be appreciated.
2
Answers
You can use Laravel Socialite to use Google and Facebook API as one of your login options.
but about your IOT device you need to create a custom function in Laravel after checking device id of IOT device with your code you can use below code to login your user and give them a JWT token.
note:
$user
is your user to login and you can get it using:Hint
For multiple API tokens use Sanctum.
Sanctum allows each user of your application to generate multiple API tokens for their account.
Reference:
Introduction:
https://laravel.com/docs/8.x/sanctum