def index():
    """List linked accounts."""
    oauth = current_app.extensions['oauthlib.client']

    services = []
    service_map = {}
    i = 0

    for appid, conf in six.iteritems(
            current_app.config['OAUTHCLIENT_REMOTE_APPS']):
        if not conf.get('hide', False):
            services.append(dict(
                appid=appid,
                title=conf['title'],
                icon=conf.get('icon', None),
                description=conf.get('description', None),
                account=None
            ))
            service_map[oauth.remote_apps[appid].consumer_key] = i
            i += 1

    # Fetch already linked accounts
    accounts = RemoteAccount.query.filter_by(
        user_id=current_user.get_id()
    ).all()

    for a in accounts:
        if a.client_id in service_map:
            services[service_map[a.client_id]]['account'] = a

    # Sort according to title
    services.sort(key=itemgetter('title'))

    return render_template(
        'invenio_oauthclient/settings/index.html',
        services=services
    )
List linked accounts.