Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token generation stuck on opening browser #151

Closed
trex005 opened this issue May 5, 2022 · 5 comments · Fixed by #156
Closed

Token generation stuck on opening browser #151

trex005 opened this issue May 5, 2022 · 5 comments · Fixed by #156
Labels
bug Something isn't working

Comments

@trex005
Copy link

trex005 commented May 5, 2022

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.

@trex005
Copy link
Author

trex005 commented May 5, 2022

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.

@Xemdo Xemdo added the bug Something isn't working label May 9, 2022
@GeoffKellyNC
Copy link

I am having this same issue but on Mac OS. It was working perfectly fine until today.

@ronoaldo
Copy link
Contributor

ronoaldo commented Jun 6, 2022

Facing the same issue on Linux amd64.

@ronoaldo
Copy link
Contributor

ronoaldo commented Jun 6, 2022

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.

@lleadbet lleadbet linked a pull request Aug 14, 2022 that will close this issue
4 tasks
@lleadbet
Copy link
Contributor

lleadbet commented Sep 1, 2022

Resolved via release of 1.1.7.

@lleadbet lleadbet closed this as completed Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants