diff --git a/ietf/utils/accesstoken.py b/ietf/utils/accesstoken.py index e3163581d..18fc4a73a 100644 --- a/ietf/utils/accesstoken.py +++ b/ietf/utils/accesstoken.py @@ -2,7 +2,8 @@ import time, random, hashlib from django.conf import settings -from django.utils.encoding import force_bytes +from django.utils.encoding import force_bytes, force_text + def generate_random_key(max_length=32): """Generate a random access token.""" @@ -14,4 +15,4 @@ def generate_access_token(key, max_length=32): # we hash it with the private key to make sure only we can # generate and use the final token - so storing the key in the # database is safe - return hashlib.sha256(force_bytes(settings.SECRET_KEY) + force_bytes(key)).hexdigest()[:max_length] + return force_text(hashlib.sha256(force_bytes(settings.SECRET_KEY) + force_bytes(key)).hexdigest()[:max_length])