from clients import clients as c
from shared.redis import client as cache


async def token():
    access_token = await cache.get('tdn_token')

    if access_token is None:
        tokens = await c.tdn_api.signin()
        await cache.set('tdn_token', tokens.accessToken, 60)

        return tokens.accessToken

    else:
        return access_token.decode()
