'Given a set of payload attributes, generate a Fernet token.'

def create_token(self, user_id, expires_at, audit_ids, methods=None, domain_id=None, project_id=None, trust_id=None, federated_info=None, access_token_id=None):

    for payload_class in PAYLOAD_CLASSES:
        if payload_class.create_arguments_apply(project_id=project_id, domain_id=domain_id, trust_id=trust_id, federated_info=federated_info, access_token_id=access_token_id):
            break
    version = payload_class.version
    payload = payload_class.assemble(user_id, methods, project_id, domain_id, expires_at, audit_ids, trust_id, federated_info, access_token_id)
    versioned_payload = ((version,) + payload)
    serialized_payload = msgpack.packb(versioned_payload)
    token = self.pack(serialized_payload)
    if (len(token) > 255):
        LOG.info('Fernet    token    created    with    length    of    %d    characters,    which    exceeds    255    characters', len(token))
    return token
