skip to Main Content

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.

2

Answers


  1. 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);
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search