Login with Mobile and otp code

How can I configure login by mobile and otp code ?

1 Like

Hi @Masoud_Hosseini,

if you have not checked then check it documentation, please.
https://docs.erpnext.com/docs/v13/user/manual/en/setting-up/articles/setup-two-factor-authentication

Maybe helpful for you.

Thank You!

@NCP Thank you for your reply, but by checking this check box, two-factor authentication will be active.
And application still needs to get the password, and after that, it accepts the OTP code.
I don’t want to pass the password here.
I need to pass Just mobile and OTP code.

1 Like

You don’t have to activate two factors authentication for mobile authentication
By default you can use mobile authentication
In system settings allow mobile as user id
But you still need to give password
If you want otp base authentication you need to setup custom authentication flow by customisation

1 Like

to get token based auth

  1. add whitelisted endpoint get-otp(user_mobile_no). It takes valid phone number, searches in users if phone exists, generates and caches phone:OTP combination, sends otp to phone.
  2. add whitelisted endpoint get_token(otp). it takes OTP, searches cache, as per user, generates OAuth Bearer Token and returns bearer token.

if you need otp based token to access api from mobile apps then this will be useful.

it is not useful for browser session based login.

3 Likes

I got an idea,
I can activate 2FA and set a static password for all users so that I can pass that password with the username from frontend and after that when user inserted the code which has sent to they , they can login into system.