# Required Configuration using Service Configuration Extension

**URL:** <https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460>\
**Category:** Extensions\
**Created:** [August 2, 2020, 1:47am UTC](https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460 "2020-08-02T01:47:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iqanansoft](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@iqanansoft](https://discuss.dev.twitch.com/u/iqanansoft)\
**Post date:** [August 2, 2020, 1:47am UTC](https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460/1 "2020-08-02T01:47:31Z")

</div>

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

 ![Captura](https://d2opxh93rbxzdn.cloudfront.net/original/2X/9/998f0afacfb4a7abc2f27be207bd856c8b948dd1.jpeg)

---

<div class="post-metadata">

**Author:** ![KaeseKuchenDEV](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/kaesekuchendev/32/9828_2.png) [@KaeseKuchenDEV](https://discuss.dev.twitch.com/u/KaeseKuchenDEV)\
**Post date:** [August 2, 2020, 8:27am UTC](https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460/2 "2020-08-02T08:27:50Z")

</div>

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](https://dev.twitch.tv/docs/extensions/life-cycle/#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: [Extensions Reference | Twitch Developers](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: [GitHub - twitchdev/bot-commander: React based frontend only extension sample that leverages Configuration Service](https://github.com/twitchdev/bot-commander) It uses the configuration service.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [August 2, 2020, 12:35pm UTC](https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460/3 "2020-08-02T12:35:26Z")

</div>

> [@KaeseKuchenDEV](#):
>
> According to the docs, the extension won’t render until the broadcaster, who uses the extension, has configured it.

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`

 ![image](https://d2opxh93rbxzdn.cloudfront.net/original/2X/7/748bc9810d343640dd364d0ff1612f6bd90e3384.png)

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

> [@iqanansoft](#):
>
> ```auto
> Twitch.ext.configuration.onChanged(() => {
> h.push("helllo!!!!!");
> h.push("bye!!!!!!!!");
> Twitch.ext.configuration.set("global", "1", JSON.stringify(h));
> document.getElementById("text1").value="testfinal2.............";
> 
> });
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![iqanansoft](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@iqanansoft](https://discuss.dev.twitch.com/u/iqanansoft)\
**Post date:** [August 2, 2020, 2:25pm UTC](https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460/4 "2020-08-02T14:25:26Z")

</div>

![](https://d2opxh93rbxzdn.cloudfront.net/original/2X/9/998f0afacfb4a7abc2f27be207bd856c8b948dd1.jpeg)

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [August 2, 2020, 3:27pm UTC](https://discuss.dev.twitch.com/t/required-configuration-using-service-configuration-extension/27460/6 "2020-08-02T15:27:07Z")

</div>

> [@iqanansoft](#):
>
> 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,

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

> [@iqanansoft](#):
>
> 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?

```
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

> [@iqanansoft](#):
>
> Is the ID broadcaster or ID CHannel necessary in Service Configuration?

I don’t understand your question.

> [@iqanansoft](#):
>
> 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));`

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.
