How to use the pyotp.otp.OTP function in pyotp

To help you get started, we’ve selected a few pyotp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github projectarkc / arkc-server / arkcserver / pyotp / totp.py View on Github external
from __future__ import print_function, unicode_literals, division, absolute_import

import datetime
import time
import ntplib

from pyotp import utils
from pyotp.otp import OTP


class TOTP(OTP):

    systime_offset = None

    def __init__(self, *args, **kwargs):
        """
        @option options [Integer] interval (30) the time interval in seconds
            for OTP This defaults to 30 which is standard.
        """
        self.interval = kwargs.pop('interval', 30)
        if self.systime_offset is None:
            try:
                c = ntplib.NTPClient()
                TOTP.systime_offset = int(c.request(
                    'pool.ntp.org', version=3).offset)
            except Exception:
                self.systime_offset = 0

pyotp

Python One Time Password Library

MIT
Latest version published 1 year ago

Package Health Score

84 / 100
Full package analysis