public static function create_standard_issuer($type, $baseurl = false) {
        require_capability('moodle/site:config', context_system::instance());
        if ($type == 'google') {
            $issuer = self::init_google();
            $issuer->create();
            return self::create_endpoints_for_google($issuer);
        } else if ($type == 'microsoft') {
            $issuer = self::init_microsoft();
            $issuer->create();
            return self::create_endpoints_for_microsoft($issuer);
        } else if ($type == 'facebook') {
            $issuer = self::init_facebook();
            $issuer->create();
            return self::create_endpoints_for_facebook($issuer);
        } else if ($type == 'nextcloud') {
            if (!$baseurl) {
                throw new moodle_exception('Nextcloud service type requires the baseurl parameter.');
            }
            $issuer = self::init_nextcloud();
            $issuer->set('baseurl', $baseurl);
            $issuer->create();
            return self::create_endpoints_for_nextcloud($issuer);
        } else {
            throw new moodle_exception('OAuth 2 service type not recognised: ' . $type);
        }
    }