'Encode the provided payload.'

def encode(self, payload):

    keys = KEYS()
    if self.asymmetric:
        keys.add(RSAKey(key=RSA.importKey(settings.JWT_PRIVATE_SIGNING_KEY)))
        algorithm = 'RS512'
    else:
        key = (self.secret if self.secret else self.jwt_auth['JWT_SECRET_KEY'])
        keys.add({'key': key, 'kty': 'oct'})
        algorithm = self.jwt_auth['JWT_ALGORITHM']
    data = json.dumps(payload)
    jws = JWS(data, alg=algorithm)
    return jws.sign_compact(keys=keys)
