Problems with `scope`

I’ve been having some problems with registering with different scopes. For example, this throws an error:

https://id.twitch.tv/oauth2/authorize?client_id=<>&response_type=code&redirect_uri=<>&scope=chat:read&state=<>

But this goes fine:

https://id.twitch.tv/oauth2/authorize?client_id=<>&response_type=code&redirect_uri=<>&scope=chat:read user:read:email&state=<>

during my tests, i’ve found out twitch (or something on twitch’s side) apparently doesnt like only one scope (or empty scope) in the request. If a put more than one correct scopes, separated by a single space, and not url-encoded, everything goes well.

The error i get, which is a weird error, is this:

Fastly error: unknown domain: <my-domain-here>.com. Please check that this domain has been added to a service.

Details: cache-ams<some-number>-AMS
  • You need to URI Encode your redirect_uri it looks like you redirect URI got &scope added to the end instead of the scope being passed to Twitch
  • Scopes are space seperated with encode to a +

Also clientID’s are public no need to redacted that

Loose example https://github.com/BarryCarlyon/twitch_misc/blob/main/authentication/user_access_generator/nodejs/views/generator.pug#L59

You error doesn’t look like a Twitch Error, but a error from your system?

So you are saying

https://id.twitch.tv/oauth2/authorize?client_id=mycid&response_type=code&redirect_uri=https://domain.com&scope=chat:read&state=somestate

Which to twitch may say: my redirect URI is https://domain.com&scope=chat:read&state=somestate so you don’t pass any scopes or state to the auth page and then after the redirect something goes awry?

  • Thats not the case. Even changing redirect_uri’s position to the end of parameters doesnt solve the problem. Url encoding any meaningful combination of the query params doesnt help, it actually sometimes makes the error happen even when there are multiple scopes entered.
  • You are right, but i currently don’t have any problems with separating scopes. Everything works when there is a second scope, (it wont work if i do an extra random space at the end, when there is only one scope: scope=chat:read )
  • I know clientid is public, but removed it since it doesnt help.
  • hhhhhhhmmmmmmmmmm. I honestly don’t know where that error’s coming from although i googled it a lot. It could be from my side, but even so, i don’t think i have much control over it. Or it might be from somewhere near Twitch’s side.
  • From what i understood, that Fastly error comes After i redirect the user, and before calling my callback url. so at the very least its happening from outside my app (my cdn is not Fastly, but im not sure if its not coming from them)
  • Note that everything works 100% fine when there is more than one scopes. Callback url is called as it should, when i don’t get that error.

The problem seems to be resolved automatically. My best guess is somewhere in the process there is something passing Fastly servers, and Fastly mistakenly throws an error. I’m not sure if Fastly resolved the problem after a while (which seems likely to me) or it was just me that did something that fixed the problem (i changed some stuff due to other problems, the code is the same though and hasn’t changed).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.