Getting "incorrect user authorization" error from Helix API

I am trying to update my stream title via the Helix API, but my OAuth token is being rejected with a HTTP 401 Unauthorized error saying “incorrect user authorization.”

I created my token with this command:

curl -X POST\
	-F 'client_id=[client-id-redacted]'\
	-F 'client_secret=[client-secret-redacted]'\
	-F 'grant_type=client_credentials'\
	-F 'scope=channel:manage:broadcast'\
	https://id.twitch.tv/oauth2/token

Which gave me the expected response:

{"access_token":"[token-redacted]","expires_in":4720809,"scope":["channel:manage:broadcast"],"token_type":"bearer"}

Then I used that token in a PATCH request, trying to change my stream title:

curl -X PATCH "https://api.twitch.tv/helix/channels?broadcaster_id=[broadcaster-id-redacted]" \
	-H 'Authorization: Bearer [token-redacted]' \
	-H 'Client-Id: [client-id-redacted]' \
	-H 'Content-Type: application/json' \
	-d '{"title":"Test"}'

So far as I understand that is the correct type of OAuth token for changing a stream title.

For the sake of debugging I also tried creating a token using Twitch OAuth Token Generator but it gave me the same HTTP 401 error (which is what should happen, so far as I know).

I’m stuck and don’t know what to do now. Those two methods are the only way I’ve ever created OAuth tokens for use with the Twitch Helix API and this is the first time I’ve gotten this error.

Thank you for any help.

You have used a client_credentials token
This token represents an application, not a user.

You need to get a user token from the broadcaster_id you want to update the channel information of.

See user Access Tokens: Authentication | Twitch Developers
And Reference | Twitch Developers

It is not no

Sounds like you got a token for YOURSELF, but not for the channel you are trying to update.

It is not no

Ah d’oh. Thanks for the clarification. I’ve never been able to fully wrap my head around OAuth.

Sounds like you got a token for YOURSELF, but not for the channel you are trying to update.

I double checked the user token I had created and realized I had accidentally used the wrong web browser and generated it for my bot, and not my actual account.

After generating a new one for my account it works as expected.

Thanks.

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