# User stream key

**URL:** <https://staging-discuss.dev.twitch.com/t/user-stream-key/42334>\
**Category:** API\
**Created:** [December 14, 2022, 2:15pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334 "2022-12-14T14:15:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvurth000100](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/bvurth000100/32/21158_2.png) [@bvurth000100](https://staging-discuss.dev.twitch.com/u/bvurth000100)\
**Post date:** [December 14, 2022, 2:15pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/1 "2022-12-14T14:15:55Z")

</div>

Ive recived the auth token, the request i send is:  
return await axios.get(“[https://api.twitch.tv/helix/streams/key](https://api.twitch.tv/helix/streams/key)”,

```auto
{
                headers: {
                    'Authorization': `Bearer ${Authorization}`,
                    'Client-Id': client_id
                }
            }
        )

```

and i get error 400,have i missed somethind that i need to add? also i saw i read that maybe its realated to **channel:read:stream\_key** where i didnt understand where do i add this

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 14, 2022, 2:17pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/2 "2022-12-14T14:17:00Z")

</div>

> [@bvurth000100](#):
>
> and i get error 400,have i missed somethind that i need to add

Whats the body message?

The HTTP code is half the information

> [@bvurth000100](#):
>
> also i saw i read that maybe its realated to **channel:read:stream\_key** where i didnt understand where do i add this

This is a `scope` which is added to the URL that users click on to provide permission for your CleintID to read/write data on the users behalf.

Scopes are touched on here [Twitch Access Token Scopes | Twitch Developers](https://dev.twitch.tv/docs/authentication/scopes)  
And how to construct the URL to auth is here [https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#authorization-code-grant-flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#authorization-code-grant-flow)

---

<div class="post-metadata">

**Author:** ![bvurth000100](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/bvurth000100/32/21158_2.png) [@bvurth000100](https://staging-discuss.dev.twitch.com/u/bvurth000100)\
**Post date:** [December 14, 2022, 2:22pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/3 "2022-12-14T14:22:26Z")

</div>

> [@BarryCarlyon](#):
>
> This is a `scope` which is added to the URL that users click on to provide permission for your CleintID to read/write data on the users behalf.

do you mean this, if so where do i add this:  
[https://id.twitch.tv/oauth2/authorize?client\_id=${CLIENT\_ID}&redirect\_uri=${redirectUrl}&response\_type=code&scope=openid+user\_read](https://id.twitch.tv/oauth2/authorize?client_id=$%7BCLIENT_ID%7D&redirect_uri=$%7BredirectUrl%7D&response_type=code&scope=openid+user_read)  
and the body of the message:  
Object {  
“error”: “Bad Request”,  
“message”: “Missing required parameter "broadcaster\_id"”,  
“status”: 400,  
}

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 14, 2022, 2:23pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/4 "2022-12-14T14:23:57Z")

</div>

> [@bvurth000100](#):
>
> do you mean this:  
> [https://id.twitch.tv/oauth2/authorize?client\_id=${CLIENT\_ID}&redirect\_uri=${redirectUrl}&response\_type=code&scope=openid+user\_read](https://id.twitch.tv/oauth2/authorize?client_id=%24%7BCLIENT_ID%7D&redirect_uri=%24%7BredirectUrl%7D&response_type=code&scope=openid+user_read)

Yes, here you have only asked for the scopes

- `openid`
- `user_read`

`user_read` is a “dead” scope and no longer documented for use

> [@bvurth000100](#):
>
> Object {  
> “error”: “Bad Request”,  
> “message”: “Missing required parameter “broadcaster\_id””,  
> “status”: 400,  
> }

You didn’t include the `broadcaster_id` in the query string parameters

So you did `https://api.twitch.tv/helix/streams/key`  
Instead of `https://api.twitch.tv/helix/streams/key?broadcaster_id=xxxxx`

where `xxxxx` is the ID of the caster you wish to get the stream key of

---

<div class="post-metadata">

**Author:** ![bvurth000100](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/bvurth000100/32/21158_2.png) [@bvurth000100](https://staging-discuss.dev.twitch.com/u/bvurth000100)\
**Post date:** [December 14, 2022, 2:28pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/5 "2022-12-14T14:28:12Z")

</div>

[https://id.twitch.tv/oauth2/authorize?client\_id=${CLIENT\_ID}&redirect\_uri=${redirectUrl}&response\_type=code&scope=openid+user\_read](https://id.twitch.tv/oauth2/authorize?client_id=%24%7BCLIENT_ID%7D&redirect_uri=%24%7BredirectUrl%7D&response_type=code&scope=openid+channel:read:stream_key),  
like this?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 14, 2022, 2:28pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/6 "2022-12-14T14:28:51Z")

</div>

No like this

`https://id.twitch.tv/oauth2/authorize?client_id=${CLIENT_ID}&redirect_uri=${redirectUrl}&response_type=code&scope=channel:read:stream_key`

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 14, 2022, 2:32pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/8 "2022-12-14T14:32:08Z")

</div>

Its

`https://api.twitch.tv/helix/streams/key?broadcaster_id=foo`

Substitute `foo` for the userID

---

<div class="post-metadata">

**Author:** ![bvurth000100](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/bvurth000100/32/21158_2.png) [@bvurth000100](https://staging-discuss.dev.twitch.com/u/bvurth000100)\
**Post date:** [December 14, 2022, 2:34pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/9 "2022-12-14T14:34:44Z")

</div>

ok now it works thank you!!

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [January 13, 2023, 2:35pm UTC](https://staging-discuss.dev.twitch.com/t/user-stream-key/42334/10 "2023-01-13T14:35:15Z")

</div>

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