question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

400 error on login.

See original GitHub issue

Have tested creds on spotify web player as well as spotify dev portal, but still getting the following error:

“400 Client Error: Bad Request for url: https://accounts.spotify.com/api/login

configuration in configuration.yaml is:

spotcast:
  username: !secret spotify_username
  password: !secret spotify_password
  accounts:
      alan:
        username: !secret spotify_username
        password: !secret spotify_password

Have tried with and without the accounts: section. Made sure both secrets and config don’t contain any leading/trailing spaces or other characters.

Running hass.io .108.9 and spotcast 2.91 (says 2.92 is available but requires hass .109 (which isn’t available yet). Ubuntu 18.04 on NUC.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:33 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
petergpcommented, May 24, 2020

It seems like a dead end with the current way to obtain an access_token since it would require bypassing Google Recaptcha.

I’ve hacked together a potential workaround. Instead of using username and password to obtain a token, I instead use two cookies that are set just after logging in called sp_dc and sp_key. It does require a manual step to obtain these cookies and they are valid for 1 year. Spotify use them to refresh the access token when it expires after 1 hour.

You can checkout how to obtain the access token with the cookies here. https://github.com/petergp/spotify-webplayer-token/blob/master/spotify_token.py

I’ll be testing this the next couple of days. You can find a working fork here: https://github.com/petergp/spotcast/

To obtain the cookies manually: • Open https://accounts.spotify.com/en/login • Open network developer tools in your browser (might require developer menu to be enabled) • Login to Spotify and select Web Player • Search/Filter for get_access_token on the network list in Developer tools • Under cookies for the request find sp_dc and sp_key.

Add these to your configuration.yaml

spotcast:
  sp_dc: <sp_dc goes here>
  sp_key: <sp_key goes here> 
3reactions
ettiennegouscommented, Apr 29, 2020

How long do the web tokens last?
Could one use manual steps to generate a token via a browser login and then store that rather?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix a 400 Bad Request Error (Causes and Fixes) - Kinsta
The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived...
Read more >
How to Fix a 400 Bad Request Error: 8 Easy Methods
The 400 bad request error is an HTTP status code that describes an error caused by an invalid request. Thus, the server can't...
Read more >
How to Fix the 400 Bad Request Error - Lifewire
The 400 Bad Request error means that the request you sent to the website server to view the page was somehow incorrect.
Read more >
What is a 400 Bad Request Error (and How Can I Fix It)?
A 400 Bad Request Error occurs when a request sent to the website server is incorrect or corrupt, and the server receiving the...
Read more >
What is HTTP error 400 and how do you fix it? - IT PRO
This error can indicate that a request has not been met successfully, or that the remote server that received the request was unable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found