Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How do I handle required scopes? #13

Closed
dialogik opened this issue Jan 4, 2021 · 3 comments
Closed

[QUESTION] How do I handle required scopes? #13

dialogik opened this issue Jan 4, 2021 · 3 comments
Labels
question Further information is requested

Comments

@dialogik
Copy link

dialogik commented Jan 4, 2021

Write your question
I have set up TESjs as described in the documentation and added ClientID and Client Secret accordingly.

const tes = new TES({
    identity: {
        id: process.env.TWITCH_CLIENT_ID,
        secret: process.env.TWITCH_CLIENT_SECRET
    },
    listener: {
        baseURL: process.env.BASE_URL,
        ignoreOldMessages: false
    }
});

And it works fine for all endpoints that don't require authentication or a specific scope. But when I try to subscribe to e.g. a subscription (which requires the channel:read:subscriptions scope), I get the error message, that the subscription is missing proper authorization.

{
  error: 'Forbidden',
  status: 403,
  message: 'subscription missing proper authorization'
}                                                               

What is the proper way to get access to those endpoints that require authorization or specific scopes?

Thanks in advance.

@dialogik dialogik added the question Further information is requested label Jan 4, 2021
@mitchwadair
Copy link
Owner

mitchwadair commented Jan 4, 2021

Hi!

The way Twitch's EventSub system works is that authorization is handled internally and tied to a client id. So, you'll have to authorize your client to have access to that scope. If you are unfamiliar with this, you can check out the doc here.

If you are using TESjs for personal use it should be as simple as using the OAuth Implicit Grant Flow. Just build yourself a URL with your client id and localhost as your redirect uri (make sure it is registered on dev.twitch.tv for your application's OAuth Redirect URLs). If you are creating a service that other people can use, you'll have to set up your authentication similarly for that as well, but with some sort of user-facing website (using whatever authorization flow makes sense for your app). Once your app has been authenticated with the correct scopes for whatever you need, it'll be good to go!

Hopefully this helps!

@dialogik
Copy link
Author

dialogik commented Jan 4, 2021

I am (currently) just using it for my own purposes. I followed your recommendation with the implicit flow and it worked. Thanks a lot.

@dialogik dialogik closed this as completed Jan 4, 2021
@mitchwadair
Copy link
Owner

Happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants