Home > Software engineering >  REST API authentication for multiple devices
REST API authentication for multiple devices

Time:12-26

In my website a user can login in 3 ways

  1. Pass the email & password
  2. Login with Google and Facebook
  3. 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.

CodePudding user response:

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.

Auth::login($user);

note: $user is your user to login and you can get it using:

$user = User::find(write_your_user_id);

CodePudding user response:

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

  • Related