scholtzan / homebridge-rusty-spotify

Spotify plugin for Homebridge written in Rust
MIT License
14 stars 5 forks source link

Can't generate config #13

Open gamarrar opened 3 years ago

gamarrar commented 3 years ago

Hi there,

trying to generate the config using the provided script I get the following:

./generate_config --client_id=XXXXXXXXXXX --client_secret=XXXXXXXXX --username=XXXXX Couldn't read cache at: .cache-XXXXXX Usinglocalhostas redirect URI without a port. Specify a port (e.g.localhost:8080) to allow automatic retrieval of authentication code instead of having to copy and paste the URL your browser is redirected to. Enter the URL you were redirected to:

and I can't continue from that point. If I provide http://localhost/callback it keeps asking until it fails with the following error:

Enter the URL you were redirected to: Traceback (most recent call last): File "./generate_config", line 68, in <module> main() File "./generate_config", line 54, in main token_info = auth.get_access_token(code, as_dict=True) File "/home/pi/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 508, in get_access_token error_description=error_payload['error_description']) spotipy.oauth2.SpotifyOauthError: error: invalid_request, error_description: code must be supplied

Is there anything that I've missed while configuring?

Thanks

scholtzan commented 3 years ago

It looks like you are running the script in the command line of a Raspberry Pi. The script needs to be executed in an environment where it can open a web browser (macos, Windows, any Linux with a GUI installed should work). Running the script will open a web browser asking you to authenticate to Spotify which is required to retrieve the refresh_token.

deepin125 commented 3 years ago

I got around this issue by running in headless mode. I modified the generate_config python code. From there you can click on the generated uri. I used the homebridge console via the web browser to do the entire install. I did have to install apt-get python3-pip to install the spotipy module. auth = spotipy.SpotifyOAuth( args.client_id, args.client_secret, args.redirect_uri, username=args.username, scope=scope, show_dialog=False, open_browser=False ) Don't worry about that couldn't read cache error, its benign. I could put a PR for an option to run in headless mode if someone wanted, it might be a nice option to have for people using the raspberry pi in headless setups.

scholtzan commented 3 years ago

Cool! Feel free to open a PR.

dwh2427 commented 3 years ago

Struggling to do this as a bit of an all round amateur. Anyone willing to do a quick screen share with me in return for a few virtual coffees?

moshed commented 3 years ago

@dwh2427 which part are you having issues with? the headless pi code change?

RobBuijs commented 2 years ago

Tried the same on raspberry, with the headless fix @deepin125 suggested. Now, I'm running into

./generate_config:56: DeprecationWarning: You're using 'as_dict = True'.get_access_token will return the token string directly in future versions. Please adjust your code accordingly, or use get_cached_token instead.

balbukh commented 2 years ago

It looks like you are running the script in the command line of a Raspberry Pi. The script needs to be executed in an environment where it can open a web browser (macos, Windows, any Linux with a GUI installed should work). Running the script will open a web browser asking you to authenticate to Spotify which is required to retrieve the refresh_token.

@scholtzan I have the following error:

pi@raspberrypi:~ $ ~./generate_config --help -bash: ~./generate_config: No such file or directory

Run it from windows powershell console. Browser is not opened.