Spotify.ahk
Spotify.ahk copied to clipboard
Spotify authorization page not opening automatically
The Spotify authorization page does not open when I create a Spotify object, not even with an unmodified version of Example Hotkeys.ahk. This has led to my not being able to use any hotkeys for Spotify. I have tried going to the link directly from the source code, but, even though everything seems to authorize fine then, Spotify.ahk still does not work.
Spotify version: 1.0.91.183.g259b84fa (Windows Store version) AutoHotkey version: 1.1.30.00 Operating System: Windows 10 Home 64-bit Version 1803 (OS Build 17134.345)
I have had the same results on a build from around a week ago and the latest one as of the time of my writing this. Windows, AutoHotkey, and Spotify are all up-to-date.
That's odd, the web authorization page should open in your default browser, as it uses the Run command to open it. I'm not sure why Run would fail, or why the web auth would fail when going directly to the URL. After you authorize Spotify.ahk with the direct link were you redirected to another page (and if so, what did it say)? Also, what is your default browser (if you don't mind)?
Hello, CloakerSmoker! Thank you for responding so fast.
My default web browser is Firefox (Quantum). I tried setting it to Chrome real quick for the sake of seeing if it was just Firefox getting in the way, but even then the authorization page never opened automatically.
I authorized Spotify.ahk with the direct link with Chrome, and everything went smoothly until it went to localhost:8000. I got an ERR_CONNECTION_REFUSED at that point.
When Spotify.ahk started for the very first time, Windows asked to allow it through the Windows Firewall, and I did. I have no third party firewall. I tried turning off the firewall real quick then authorizing again, still to the same error message in Chrome.
My computer's failing to connect to the server Spotify.ahk is hosting looks like it could be the problem here. Oddly enough, I don't remember seeing any message like that the first time I followed the direct link in Firefox.
Are you running it as admin? Probably won't work under a standard user. Also check to see if you have any other program hosting on/using port 8000
Running it as admin did not help. As far as I know, I don't have anything else running on 8000. I tried setting it to 8001 in the source and accounts.spotify.com started complaining that I had an invalid redirect URI.
If you'd like to try another port, 3000 is authorized on Spotify's end. For a quick and dirty solution, comment out lines 22 - 32 of Spotify.ahk, and add this after line 32, but before this.FetchTokens() is called
InputBox, auth, Enter the "code" portion of the URL you are redirected to (without "code=")
this.auth := auth
Just open the link manually and copy the big string in the URL after code= into that inputbox, which should get around the need for a working local server to get the code from the request. This should fix your problem until I can get a solid fix for whatever is going wrong with the local server.
Alright. I commented out line 22- 32 of Spotify.ahk, which was everything inside an else statement. I pasted your code right below it, still inside StartUp(). Running Example Hotkeys.ahk as Administrator, I opened the direct link inside the (now commented out) code. I copied the code after "code=" that I got redirected to, then I then pasted that code into the new input box. After this, the hotkeys still do not work.
In doing this though, I discovered a few things:
- If I made the
ifstatement return false, the server started working as normal and the link started opening automatically. - By looking at
HKCU\Software\SpotifyAHKin RegEdit, I found AutoHotkey is storing the token just fine. - By having the script print
refreshin amsgbox, I found AutoHotkey is also reading the token and storing it intorefreshjust fine.
So the link must not have been opening because Spotify.ahk was reading the token correctly the whole time. Regardless, the hotkeys do not work whether the if returns true or false.
Thanks again for the help.