def authkey(wiki_user): key = Key(user=wiki_user, description="Test Key 1") secret = key.generate_secret() key.save() auth = "%s:%s" % (key.key, secret) header = "Basic %s" % base64.b64encode(auth.encode()).decode() return AuthKey(key=key, header=header)
def authkey(wiki_user): key = Key(user=wiki_user, description='Test Key 1') secret = key.generate_secret() key.save() auth = '%s:%s' % (key.key, secret) header = 'Basic %s' % base64.encodestring(auth) return AuthKey(key=key, header=header)
def authkey(wiki_user): key = Key(user=wiki_user, description='Test Key 1') secret = key.generate_secret() key.save() auth = '%s:%s' % (key.key, secret) # TODO: Once Python 2/3 is gone, replace encodestring by encodebytes header = 'Basic %s' % base64.b64encode(auth.encode('utf-8')).decode('utf-8') return AuthKey(key=key, header=header)
def user_auth_key(): u = user(username="******", email="*****@*****.**", save=True) key = Key(user=u) secret = key.generate_secret() key.save() return Object( user=u, key=key, secret=secret, )