Token generation stuck on opening browser
Closed this issue · 5 comments
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.
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
As I now have deployed the machine, I may not be as useful in debugging why the problem occurred in the first place, but if you need additional information, I can try to get access to it again.
I am having this same issue but on Mac OS. It was working perfectly fine until today.
Facing the same issue on Linux amd64.
I guess I managed to find the issue. I had the same issue with my experiment for a Youtube CLI. The code that handles the callback at '/' will handle the request for other things, such as /favicon.ico and that may confuse the token handling logic and not close the channel, making that step stuck at the opening browser part.
I've sent a PR since this looked like a trivial fix once we nail the problem, off course.
Resolved via release of 1.1.7.