Incorrect user authorization


I have registered my application and generated OAuth token through Twitch CLI.

get channel information: url= ‘’ runs without error but when I try to get game analytics using url = ‘’ or editor details using url = '’
I get the below error:

"error": "Unauthorized",
    "status": 401,
    "message": "incorrect user authorization"

how is the Token working for a few commands and not for all. Any help?


You appear to have create a client credentials token, which generally is fine for calling public data endpoints.

To call the editors endpoint you need permission from the broadcaster, which is acheived by generating a User token with the relevant scope attached.

As you need a token that represents a user, a client credentials represents no one (well technically you clientID which isn’t a user)

As per

OAuth user token required
Required scope: channel:read:editors

As for games, well you’ll need to be part of an organistation that owns a game!

Gets a URL that game developers can use to download analytics reports (CSV files) for their games.

OAuth token required
Required scope: analytics:read:games

A user token is

See also

Thank you.

how do I “Send the user you want to authenticate to your registered redirect URI:”?

Redirect URL is http://localhost

Normally your oAuth flow will reside on a website

So the link to start the auth process is housed in an <a href="">Login with Twitch</a>

This is an example that implements implicit auth, which generates a token that is non refreshable, so generally not the token you need but will illistrate the flow

The TwitchCLI will do this with the -u flag as well

It’ll open the web browser from the command line to do the auth with

The guide:

thanks again. I did the below:

  1. changed the redirect url for my app http://localhost:3000
  2. twitch token -u -s “user:read:email”
  3. Redirected to app for authorization >> authorized it
  4. What next?
user ~ % twitch token -u -s "user:read:email"
Opening browser. Press Ctrl+C to cancel...

Where will I get the user token?

Did the browser page then go “you can close the window now”?

Or did it hang?

Worse case you ran into a twitch-cli weird so you can just go and build the proper oAuth flow instead of the TwitchCLI for testing.

The TwitchCLI generally doesn’t expose the token to you as it’s for use internally by the TwitchCLI for testing API endpoints with. But will will display the token when it does the code to token exchange.


You can also probably pull the token from the .env file for the rig, which on MacOS is in ~/.twitch-cli/.twitch-cli.env I don’t know on windows.

But again, the CLI is for testing in the CLI not really for extracting the token for use elsewhere.

Yes, browser page showed " Feel free to close this browser window."

Did the console display an output similar to my screenshot?


nshaloo@38f9d33e3fd7 ~ % twitch token -u
Opening browser. Press Ctrl+C to cancel…

Weird, time to skip the CLI and possibly report an issue

And build a proper oAuth flow instead.

The browser displays “Feel free to close this browser window.” but no user token generated.
no response on console.

Thanks, will do that!

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