Token generation stuck on opening browser

Windows 11, I’ve tried with cmd and powershell both with normal privileges and run as administrator.
This is happening only on one computer, I can not replicate it on others.

I have my CLI configured and am setting up a token.

.\twitch.exe token -u -s "channel:read:predictions channel:manage:predictions"

The login works perfectly and subsequent attempts skip user authentication. The browser then redirects to:
http://localhost:3000/?code=BLAH&scope=channel%3Aread%3Apredictions+channel%3Amanage%3Apredictions&state=BLAH

And the browser says:
Feel free to close this browser window.

This clearly indicates that the CLI has received the response. In fact, if I try to refresh, the host can not be reached, showing that the response was processed and the port was even closed.

However, when I go back to the command prompt, it is still stuck on:
Opening browser. Press Ctrl+C to cancel...

My hope was that this is just a UI bug and the oath was actually finalized, but canceling and then trying to run the API commands I am not authorized.

Any ideas on how I can get around this?
One idea I had was manually setting the OAuth info for the CLI somehow since I can grab it from the URL, but I can’t find any documentation on how to do this.

You probably should raise this as an issue over on GitHub - twitchdev/twitch-cli: The official Twitch CLI to make developing on Twitch easier.

I will also post it there. Thank you.

1 Like

For anyone looking in the future:
I dug through the code and found that the twitch CLI uses viper to store its config.

Looking through viper, I found on windows it stores “environment” variables in:
%APPDATA%/AppName
In this case:
%APPDATA%/twitch-cli
e.g. C:\Users\YourUsername\AppData\Roaming\twitch-cli

You can edit the needed variables there and the CLI starts working perfectly. You will definitely want the refresh token.

I’d recommend setting your token expiration to the past, so it refreshes automatically
TOKENEXPIRATION=2022-01-01T20:00:00.000000Z