Go to the Spotify Developer Dashboard → create an app. https://developer.spotify.com/dashboard
In the app Settings, add a Redirect URI you can receive in a browser, http://127.0.0.1:8888/callback, then Save.
Open this URL in your browser (replace YOUR_CLIENT_ID
and URL-encode the redirect URI):
https://accounts.spotify.com/authorize?client_id=YOUR_CLIENT_ID
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%2Fcallback
&scope=user-modify-playback-state%20user-read-playback-state
&state=xyz123
Log in, approve. Spotify will redirect to:
http://localhost/callback?code=AUTH_CODE&state=xyz123
Copy the code
value. (Those scopes are what you need to transfer/play/pause and to read device status.)