code: def to_uri(self, type, label, issuer, counter=None):
          
          type = type.lower()
  
          if type not in ('hotp', 'totp'):
              raise ValueError('type must be hotp or totp')
  
          if type == 'hotp' and not counter:
              raise ValueError('HOTP type authentication need counter')
  
          # https://code.google.com/p/google-authenticator/wiki/KeyUriFormat
          url = ('otpauth://%(type)s/%(label)s?secret=%(secret)s'
                 '&issuer=%(issuer)s')
          dct = dict(
              type=type, label=label, issuer=issuer,
              secret=self.encoded_secret, counter=counter
          )
          ret = url % dct
          if type == 'hotp':
              ret = '%s&counter=%s' % (ret, counter)
          return ret
docs: Generate the otpauth protocal string.
  
          :param type: Algorithm type, hotp or totp.
          :param label: Label of the identifier.
          :param issuer: The company, the organization or something else.
          :param counter: Counter of the HOTP algorithm.