import secrets
from datetime import datetime, timedelta


def generate_token():
    return secrets.token_urlsafe(48)


def expiration(hours=24):
    return datetime.utcnow() + timedelta(hours=hours)


def is_expired(expire_dt):
    return not expire_dt or expire_dt < datetime.utcnow()