ersel / spotify-cli-mac

🎶 A nodejs app to control Spotify without leaving your terminal. 🎶
MIT License
183 stars 28 forks source link

spotify token asks for config twice #21

Closed rebz closed 7 years ago

rebz commented 7 years ago

When running spotify token it asked for my ID and Secret twice. See screenshot.

spotify-token

ersel commented 7 years ago

Oh thanks for reporting @rebz , I see why this is happening.

So by default we check if creds are set or not, this is done here: https://github.com/ersel/spotify-cli-mac/blob/master/index.js#L53

So regardless what command you're trying to run, we check if creds are set or not. If they are not set, we call the setTokens function to let user set tokens.

In your case, you ended up setting tokens TWICE because of else block on Line 52. Once creds were set, your action was resolved and CLI ended up asking for your tokens again (because you run spotify token, this would not have happened if you had run spotify mute for instance...)

So there are 2 things we should do I think:

1 - Remove the misleading line from README.md that you need to run spotify token to set your creds, running just spotify should suffice on the first ever run.

2 - We should short-circuit the app within the else block on Line 52, if user has run spotify token. This would involve checking for command line args then short circuiting by doing: return process.stdout.write('\n');

Hope that clarifies what happened, I would be happy to accept a PR addressing above if you have time to look into it.

ersel commented 7 years ago

This has been fixed. Thanks @QuadDepo