Required Configuration using Service Configuration Extension

Hi, i need help about “service Configuration Extension”,if i have this code

Twitch.ext.onAuthorized(auth => {
});

var h=new Array();
document.getElementById("buttonconf").addEventListener("click", fun1); 

function fun1(){
          h.push("helllo!!!!!");
         h.push("bye!!!!!!!!");
	Twitch.ext.configuration.set("global", "1", JSON.stringify(h));
        document.getElementById("text1").value="testfinal1.............!";
}

Twitch.ext.configuration.onChanged(() => {
          h.push("helllo!!!!!");
         h.push("bye!!!!!!!!");
	Twitch.ext.configuration.set("global", "1", JSON.stringify(h));
        document.getElementById("text1").value="testfinal2.............";

});

always tells “required configuration”, it never lets me activate the extension …
i’m going crazy ,can’t find error

image with configuration service extension

According to the docs, the extension won’t render until the broadcaster, who uses the extension, has configured it. Source:

If you do require configuration, the extension won’t render until the broadcaster has configured it. In this case, you must specify versions of the broadcaster and developer configuration segments in two places. First, set the required versions on the Extensions manager Capabilities tab. Second, on the extension side, set versions when you set configuration (via the helper method or the API). Note that these two settings are compared when the channel is loaded. If they do not match, the extension will not load.

If you have already done this, or are not even able to reach that far to configure it, maybe this endpoint helps you: https://dev.twitch.tv/docs/extensions/reference#set-extension-required-configuration

I dont know if this really is what you are looking for. So please specify a bit what you want to do, what you expect it to do and what it actually does

always tells “required configuration”

Where does it say this? On the webpage or when you try run your code? Maybe this example project may also help you: https://github.com/twitchdev/bot-commander It uses the configuration service.

This is true, because you set the “Broadcaster Writable Channel Segment Version” to a value. You can leave this blank if you don’t require the extension to be configured to function.

The problem here is you set the developer and broadcaster required versions to “1”, but in your code, you set the global version and config.

This causes a number of issues.

  • First. you cannot set the “global” config via .set that’s restricted to the API for security reasons, otherwise everyone that installs your extension can change everyone elses configuration.
  • Second, you never set the developer and broadcaster segments version to “1” which is required because you set this value in the console.

Fixes:

  1. Remove the value from the developer setting in the console
  2. Change you code to set the broadcaster segment, not global

Twitch.ext.configuration.set(“broadcaster”, “1”, JSON.stringify(h));

Also this is bad because the moment you load the configuration you are then changing the configuration. So the cached configuration is immediately out of date.

onChanged loads/populates the configuration from Twitch into your code, and can be called only once per page load

1 Like

Is the ID broadcaster or ID CHannel necessary in Service Configuration?

i don’t understand

another problem…If I don’t configure a version “Developer / broadcaster Writable Channel segment”, I don’t have to indicate in .set function a version, or segment,

Twitch.ext.configuration.set("", "", JSON.stringify(data));

so … how do I retrieve the configuration for example with

Twitch.configuration.broadcaster.content
Twitch.configuration.developer.content
Twitch.configuration.global.content

with Twitch.configuration.global.content?

Yeah you don’t have to use a version, it’s option if the values are blank

window.Twitch.ext.configuration.onChanged(() => {
    console.log(window.Twitch.ext.configuration);
    global_config = window.Twitch.ext.configuration.global;
    console.log(global_config);
    if (global_config) {
        try {
            global_config.content = JSON.parse(global_config.content);
        } catch (e) {
            // jsut in case
            console.log(e);
        }
    }
});

is an example of loading config. Substiute global as needed

I don’t understand your question.

Correct if you are not using versions then you don’t have to declare a version.

You can also not require any version at all and then you don’t have the configuration block you are having.