def _create_auth(team, timeout=None):
    """
    Reads the credentials, updates the access token if necessary, and returns it.
    """
    url = get_registry_url(team)
    contents = _load_auth()
    auth = contents.get(url)

    if auth is not None:
        # If the access token expires within a minute, update it.
        if auth['expires_at'] < time.time() + 60:
            try:
                auth = _update_auth(team, auth['refresh_token'], timeout)
            except CommandException as ex:
                raise CommandException(
                    "Failed to update the access token (%s). Run `quilt login%s` again." %
                    (ex, ' ' + team if team else '')
                )
            contents[url] = auth
            _save_auth(contents)

    return auth
Reads the credentials, updates the access token if necessary, and returns it.