# Problems with \`scope\`

**URL:** <https://discuss.dev.twitch.com/t/problems-with-scope/31594>\
**Category:** API\
**Created:** [May 8, 2021, 8:02am UTC](https://discuss.dev.twitch.com/t/problems-with-scope/31594 "2021-05-08T08:02:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahdimmbm](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/mahdimmbm/32/12721_2.png) [@mahdimmbm](https://discuss.dev.twitch.com/u/mahdimmbm)\
**Post date:** [May 8, 2021, 8:02am UTC](https://discuss.dev.twitch.com/t/problems-with-scope/31594/1 "2021-05-08T08:02:44Z")

</div>

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

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

```

But this goes fine:

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

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

```

---

<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:** [May 8, 2021, 10:26am UTC](https://discuss.dev.twitch.com/t/problems-with-scope/31594/2 "2021-05-08T10:26:27Z")

</div>

- 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](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

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

---

<div class="post-metadata">

**Author:** ![mahdimmbm](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/mahdimmbm/32/12721_2.png) [@mahdimmbm](https://discuss.dev.twitch.com/u/mahdimmbm)\
**Post date:** [May 8, 2021, 7:53pm UTC](https://discuss.dev.twitch.com/t/problems-with-scope/31594/3 "2021-05-08T19:53:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mahdimmbm](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/mahdimmbm/32/12721_2.png) [@mahdimmbm](https://discuss.dev.twitch.com/u/mahdimmbm)\
**Post date:** [May 10, 2021, 12:53pm UTC](https://discuss.dev.twitch.com/t/problems-with-scope/31594/4 "2021-05-10T12:53:54Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [June 9, 2021, 12:53pm UTC](https://discuss.dev.twitch.com/t/problems-with-scope/31594/5 "2021-06-09T12:53:57Z")

</div>

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