Configuration is always empty when using window.Twitch.ext.configuration

Hi,

I have set a configuration panel that allows the broadcaster to set some parameters. These parameters get set OK with window.Twitch.ext.configuration.set().

However, using window.Twitch.ext.configuration to try and retrieve this info always returns an empty object.
Weird part is, I can get the configuration with postman by using twitch API.

Any idea how I can get the config using Twitch.ext.configuration?

Thanks

You do have something like


window.Twitch.ext.configuration.onChanged(() => {
    var broadcaster = window.Twitch.ext.configuration.broadcaster;
    if (broadcaster) {
        if (broadcaster.content) {
            var config = {};
            try {
                config = JSON.parse(broadcaster.content);
            } catch (e) {
                console.log(e);
            }

            //do stuff with config
        }
    }
});

To read the config you must use window.Twitch.ext.configuration.onChanged to trigger config to be loaded

That’s how I have it in my code, but config remains ‘undefined’ (exact same result when using your code from above).

Do I have to pass any auth parameters somewhere, maybe?

No

That could suggest you didn’t set the segment you think you did.

Or you might have the config service disabled on this version of the extension (version being an extension version, not a config version) and you wrote to a different version (if you have multiple versions).

So check the extension has the config service enabled in the console.
Reinstall the extension to the test channel.
And test it again

If you are testing in the rig, you might have set a different channel for the view than you get setting/getting against using postman. So check that too.

I have only one version and i’m testing on localhost (no rig).

Here is how the config is set, which I believe sets the segment to “broadcaster”.
window.Twitch.ext.configuration.set("broadcaster", '', streamerConfig);
with streamerConfig being some input from the broadcaster.

Here’s the API call that returns the correct data:
https://api.twitch.tv/extensions/[my_extension_id]/configurations/segments/broadcaster?channel_id=[my_test_channel_id]. It returns:

{
    "broadcaster:[my_test_channel_id]": {
        "segment": {
            "segment_type": "broadcaster",
            "channel_id": "[my_test_channel_id]"
        },
        "record": {
            "content": "test string config"
        }
    }
}

is "test string config" a string or a JSON encoded string?

Not that it should make a difference (I’ve only ever done JSON blobs never a “true” string)

I don’t see anything else obviously wrong.

And I’m assuming your onChanged isn’t “inside” another function? Which could potentially cause an issue. (not tested myself but worth to check, all mine are top level)
Also check your don’t have more than one call kicking about.

Yes it’s JSON encoded and onChanged is on top level. I have onContext and onAuthorized at top level, too, but I don’t think this can create a conflict?

Kinda at a loss :upside_down_face: I’m just including an API call in there for now; it’s clunky AF but seems to get the job done.

Yeah I’m out of the obvious ideas. Since similar calls work for me in a released extension.

Did you we try uninstalling the extension and reinstalling?

And might be worth cracking open dev tools and going digging see if ti throws up anything interesting

Just tried that but no luck here. I’m developing the extension with React, could this impact it at all?

I don’t know I don’t use react.

But it would seem unlikely since your logged a undefined anyway

May be worth stripping react out and trying a basic HTML/JS example instead to rule it out

Will try that, thanks Barry!

Hi Arthur,

I’m having the same problem, Twitch support is refusing me the extension upload because they see a bug in the configuration option, something that works perfectly in Hosted and Rig.

Initially, I’m asking for the configuration through the API and everything is fine, but Discord has recommended me to get the information through the helper and I’m getting the same as you.

My extension is made in Vue and I am executing the onChanged inside the mounted cycle.

whenever I try to obtain a configuration value I get back undefined.

Did you manage to solve it?

This suggests the config service is disabled, or the segment was not set

@jpaaks I couldn’t get it solved.

Is the API option a no-go, for getting Twitch’s approval?

Just yesterday I received this message from another application rejection where we have been trying to solve the technical problem for 1 month.

Hey there,

From what we are seeing, the extension is failing to load the configuration from the Hosted Config Service. Looking through the request being sent to the endpoint, the JWT being generated and sent doesn’t match what we expect for that endpoint. If you could, take a look at our docs to make the fix! https://dev.twitch.tv/docs/extensions/reference#get-extension-channel-configuration

Twitch Developer Experience Team

The curious thing is that I am using what is commented in the documentation they suggest and the data comes to me as they comment.

The extension works correctly and with it the configuration via API in the Rig, in Local Text and in Hosted Test but they get an error in their test environment.

Yesterday tinkering and messing around on Twitch Dev’s Discord, I was able to get the configuration through the helper in Local and it was by configuring the “Extension Configuration Service” from the panel and refreshing the manifest.

But now I can neither refresh, nor set new values to the config

Given you never came back to your I thought you had got it working

If the extension doesn’t work, becuase your config setting code doesn’t work.
Then the extension doesn’t work, so it can’t pass review

Yeah a requirement for the config service is to have enabled it in the dev console

This is under Capabilities (greyed out as this is a screenshot from a released extension)

Review will “use the extension” under “hosted test” but force installed to one of the review channels. (Force as in bypassing any allow list restrictions).

So they are testing it on one of their own channels.

So to test, try installing to a new test channel, or clean back all the config variabels to empty/invalid and (re)install your extension and test the setup.

The Config service can be quicky in the Developer rig when using the helper to set. Personally I rarely test using the rig since I have a custom rig, behind a reverse SSH tunnel (think NGROK but without restrictions) so my live extension server handles SSL. So I can test to the Twitch Website insteasd of dealing with quirks in the rig.

I wrote a little about it on Part 5 on my Extensions Series Twitch Extensions Part 5 – Dev Environment – Barry Carlyon and my “rig” that handles compilation and serving code is on GitHub twitch_extension_blog_series/part_5/extension/extension at main · BarryCarlyon/twitch_extension_blog_series · GitHub

So I avoid the rig but serving my extension over SSL and then testing on the Twitch website, I generally avoid the rig since rig doesn’t do “what happens when a user becomes logged out of the extension to logged in” aka State Changes.

But if you are using the Config API to set config then you should avoid the quirks of the dev rig.

But you’ll probably find that if you are using the rig, you have the frontend view and config view set to different broadcasters, great for spot testing, but I wouldn’t use the rig for any actual config setting.

You can also look at adding an onError callback to log any errors that get returned

Or whip out inspector and trace the calls in the network tab and check its doing what you think it’s doing.

And short of being in fron of your machine to look at what your setup is and how it’s interacting with your code it’s tought to debug this.

Especially since if you gave me your code I predict it would just work on my machine.