'Django Rest + FireBase For Phone number Authentication with OTP

Hello everyone I Dont have much code to display as I am hard time gaining knowledge regarding firebase phone number authentication. Story is I am not using firebase db my clients may be international so I want to use minimal authentication mechanism for sending otp codes and we came with firebase as ultimate solution as It allows 10000 sms per month and it fulfills our need. The documentation I Found in web are totally based on firebase database where front end directly hits firebase database and backend doesnot even need to take care in such circumstances.

I Just want to verify user otp code and provide refresh token and access token with simple jwt ( I dont know if this is correct or not) I Found only best two docs or articles that best fits my requirement. Article 1

Article 2

This is my custom user model

class User(AbstractBaseUser, PermissionsMixin):

    CLIENT=1
    DATA_ENTRY=2

    ROLE_CHOICES = (
        (CLIENT, 'CLIENT'),
        (DATA_ENTRY, 'DATA_ENTRY')
    )


    phone_number = models.CharField(_("phone number"), max_length=60, unique=True)
    first_name = models.CharField(_("first name"), max_length=150, blank=True)
    middle_name = models.CharField(_("middle name"), max_length=150, blank=True)
    last_name = models.CharField(_("last name"), max_length=150, blank=True)
    role = models.PositiveSmallIntegerField(choices=ROLE_CHOICES, blank=True, default=1)
    email = models.EmailField(_("email address"), blank=True)
    is_staff = models.BooleanField(
        _("staff status"),
        default=False,
        help_text=_("Designates whether the user can log into this admin site."),
    )
    is_active = models.BooleanField(
        _("active"),
        default=False,
        help_text=_(
            "Designates whether this user should be treated as active. "
            "Unselect this instead of deleting accounts."
        ),
    )
    date_joined = models.DateTimeField(_("date joined"), default=timezone.now)

    USERNAME_FIELD = "phone_number"
    REQUIRED_FIELDS = []

It will be huge help if anyone can guide me through this thank you community.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source