Is this not possible or am I missing something? Predictions EndPoint

I’m following the documentation from Prediction | Twitch Developers So I created an application and with it’s client id and secret I’m redirecting the user to login at:

https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=TW_CLIENT_ID&redirect_uri=CB_URL&force_verify=true&scope=channel:manage:predictions

With the corresponding client id and redirect url.

With the response I request an access token by doing a POST to: https://id.twitch.tv/oauth2/token?client_id=TW_CLIENT_ID&client_secret=TW_CLIENT_SECRET&code=CODE&grant_type=authorization_code&redirect_uri=CB_URL

with the CODE been the code received in the previous step.

With this access token I then do a POST like this (REST Client)

POST https://api.twitch.tv/helix/predictions
Authorization: Bearer {{token}}
Client-Id: {{clientId}}
Content-Type: application/json

{
	"broadcaster_id": "___",
	"title": "Test prediction",
	"outcomes": [{ "title": "Option 1" }, { "title": "Option 2" }],
	"prediction_window": 300
}

ClientId is my application client id and token is the access token we got in the previous steps. Broadcaster ID is the ID of the broadcaster account I’m a moderator for (maybe this is the key to the issue) When sending this post I get back.

{
  "error": "Unauthorized",
  "status": 401,
  "message": "The ID in broadcaster_id must match the user ID found in the request's OAuth token."
}

I’m assuming that only a broadcaster himself can use this endpoint? But if that’s the case why it would even ask for a broadcaster id?

Is it not possible to a moderator to use this endpoint?

Correct

The list is many for why this is the case. TLDR: it helps you make sure you are talking to the right persons data.

1 Like

Thanks Barry. Will try to test with some boilerplate responses and then send to the broadcaster for him to test.

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