# Is it possible to EventSub in an extension front end?

**URL:** <https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234>\
**Category:** Extensions\
**Created:** [February 1, 2023, 10:02pm UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234 "2023-02-01T22:02:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tf2casperr](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/tf2casperr/32/9301_2.png) [@tf2casperr](https://discuss.dev.twitch.com/u/tf2casperr)\
**Post date:** [February 1, 2023, 10:02pm UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234/1 "2023-02-01T22:02:44Z")

</div>

Hello - I am trying to use EventSub websockets to get channel follows in an extension front end. I can connect to the EventSub websocket just fine and I receive the welcome message, but when I try and subscribe to the event I get a 401 - “invalid JWT used”. I am using the helixToken that the extension onAuthorized function returns.

```auto
    Twitch.ext.onAuthorized(function (auth) {
        console.log(auth);

        const socket = new WebSocket('wss://eventsub-beta.wss.twitch.tv/ws');

        let websocket_id = null;

        // Connection opened
        socket.addEventListener('open', function (event) {
            console.log("open", event);
        });

        // Listen for messages
        socket.addEventListener('message', function (event) {
            const data = JSON.parse(event.data);
            console.log('Message from server ', data);

            if (data.metadata.message_type === 'session_welcome') {
                websocket_id = data.payload.session.id;
            }

            $.ajax({
                url: 'https://api.twitch.tv/helix/eventsub/subscriptions',
                type: 'POST',
                headers: {
                    'Client-ID': 'auth.clientId',
                    'Authorization': 'Extension ' + auth.token, // Using token instead of helixToken for devrig.
                    'Content-Type': 'application/json'
                },
                data: JSON.stringify({
                    "type": "channel.follow",
                    "version": "1",
                    "condition": {
                        "broadcaster_user_id": auth.channelId
                    },
                    "transport": {
                        "method": "websocket",
                        "session_id": websocket_id
                    }
                }),
                success: function (data) {
                    console.log("success", data);
                }
            });

        });
    });

```

Should this be possible with the extension token, and if so what else might be the issue?

Thanks

---

<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:** [February 1, 2023, 11:56pm UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234/2 "2023-02-01T23:56:09Z")

</div>

The HelixToken doesn’t represent a user.  
As such it cannot be used with EventSub WebSockets.

HelixToken is only valid for calling the “regular” API (excluding anything scoped)

To put it another way: no an extension frontend cannot utilise EventSub as there is no sensible way to get a user token to use in order to access EventSub.

Additionally with the upcoming changes to follows, you will need a broadcasters token, and you can’t leak that in an extension front end.

---

<div class="post-metadata">

**Author:** ![tf2casperr](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/tf2casperr/32/9301_2.png) [@tf2casperr](https://discuss.dev.twitch.com/u/tf2casperr)\
**Post date:** [February 2, 2023, 10:25am UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234/3 "2023-02-02T10:25:05Z")

</div>

Thanks as ever Barry for your quick and helpful response!

Could you please elaborate on the upcoming changes to follows? I’ve looked through the announcements and can’t see anything about follows changes. Will this affect the regular [https://api.twitch.tv/helix/users/follows](https://api.twitch.tv/helix/users/follows) endpoint?

Thanks

---

<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:** [February 2, 2023, 10:26am UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234/4 "2023-02-02T10:26:19Z")

</div>

> [@tf2casperr](#):
>
> Will this affect the regular [https://api.twitch.tv/helix/users/follows](https://api.twitch.tv/helix/users/follows) endpoint?

Yes

> [@tf2casperr](#):
>
> I’ve looked through the announcements and can’t see anything about follows changes

It’s broadly believed the data is becoming scoped. But details are to follow.

I know changes have been announced as on the way but what those changes are hasn’t been confirmed

---

<div class="post-metadata">

**Author:** ![tf2casperr](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/tf2casperr/32/9301_2.png) [@tf2casperr](https://discuss.dev.twitch.com/u/tf2casperr)\
**Post date:** [February 2, 2023, 2:02pm UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234/5 "2023-02-02T14:02:36Z")

</div>

Thanks again.

As a front-ender with an extension entirely reliant on hitting the follows endpoint without an EBS, I await those details with bated breath 🙃

The original query was of course kindly answered already, so I’ll mark as solved, cheers!

---

<div class="post-metadata">

**Author:** ![jbulava](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/jbulava/32/6777_2.png) [@jbulava](https://discuss.dev.twitch.com/u/jbulava)\
**Post date:** [February 2, 2023, 4:50pm UTC](https://discuss.dev.twitch.com/t/is-it-possible-to-eventsub-in-an-extension-front-end/43234/6 "2023-02-02T16:50:01Z")

</div>

We’ve discussed on the TwitchDev broadcasts that changes to follows were coming and that we would be introducing new endpoints with scopes in an open beta to replace the existing endpoint. No announcement was being published on the forums until we had a solid timeline planned. You can expect that to happen very very soon!
