Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect my spotify account #152

Open
Lenteguppie opened this issue Sep 14, 2020 · 77 comments
Open

Cannot connect my spotify account #152

Lenteguppie opened this issue Sep 14, 2020 · 77 comments

Comments

@Lenteguppie
Copy link

When I want to configure your Skill with my Spotify credentials I get an error page with the error: INVALID_CLIENT: Failed to get client. Am I doing something wrong?

@forslund
Copy link
Owner

Recently Spotify disabled the skill's API key so the skill can currently not be used. I'm trying to get through to Spotify to get this up and running again I'm also working on a workaround where users can supply their own key to the skill. got a POC on that but it'll require some more work to get it user friendly.

@Lenteguppie
Copy link
Author

Ok, thanks! I am looking forward to it!

@fermulator
Copy link

same

The observation

Recently noticed:

 00:51:32.905 | INFO     |   712 | __main__:handle_utterance:72 | Utterance: ['play classical music on spotify']
 00:51:33.117 | INFO     |   706 | Playback Control Skill | Resolving Player for: classical music on spotify
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout
 00:51:40.423 | INFO     |   706 | Playback Control Skill | Playing with: mycroft-spotify.forslund
 00:51:40.696 | ERROR    |   706 | SpotifySkill | User info has been set but Auth failed.
 00:51:40.958 | INFO     |   706 | Playback Control Skill | Audio service status: {}

I confirmed my user/pass is correct in the config, so then retried the "Connect" button in the account skills
https://account.mycroft.ai/skills

it punts me to something like:
https://accounts.spotify.com/authorize?client_id=SNIP&redirect_uri=https%3A%2F%2Fapi.mycroft.ai%2Fv1%2Fauth%2Fcallback&scope=user-library-read+streaming+playlist-read-private+user-top-read+user-read-playback-state&state=SNIP&access_type=offline&response_type=code

browser shows: INVALID_CLIENT: Failed to get client

@forslund - per discussion;

System Versions

  • mycroft-core 20.8.0
(.venv) pi@picroft:~/mycroft-core/skills/mycroft-spotify.forslund $ git status
On branch 20.02
Your branch is behind 'origin/20.02' by 1 commit, and can be fast-forwarded.

@fermulator
Copy link

What is a bit bonkers to me is:

  1. Google and Alexa do this ... did their systems get blocked too?
  2. https://developer.spotify.com/documentation/web-api/ specifically talks about how to achieve integration for develop "My App" ... hmmm

@fermulator
Copy link

Found:
https://developer.spotify.com/terms/

Do not use the Spotify Platform, Spotify Content, Spotify Service, or Spotify Marks in any way to create a voice-enabled SDA that enables a user to control with his or her voice, or any kind of voice assistant that provides voice-control functionality without prior written authorization from Spotify.

@fermulator
Copy link

This sucks 😢 , we will try to go through official spotify channels to get this resolved.

@Y0ngg4n
Copy link

Y0ngg4n commented Oct 1, 2020

@fermulator any Updates from Spotify?

@fermulator
Copy link

Nothing yet;

  1. tried: https://developer.spotify.com/terms/#report-form-modal about a week ago
  2. seeing if I can find a colleague their to learn more about the process

@forslund indicated to me offline he contacted them as well (not sure by which method)

The other way I know of is:
https://developer.spotify.com/support/

App Integration Application To build and distribute an application that using commercial integration, you must log in and create a client ID. You will be asked to fill in a form to submit an Application Integration Request.

But obviously this already went through that process? (@forslund can confirm) - but the application/request is so basic, I'm not sure how Spotify intends to approve or denote applications that REQUEST for written consent to have their application control Spotify via voice...

@Y0ngg4n
Copy link

Y0ngg4n commented Oct 1, 2020

Yes but same here with Deezer. Wrote them approximately 5 Emails and they sayed to me write them on twitter but no answer yet.

@forslund
Copy link
Owner

forslund commented Oct 1, 2020

I started the "HW partner application" process, I also reached out through their Developer support (which I think is new) asking if there were some other channel to go through for this. They confirmed that it was the HW partner form that was needed. So it's the waiting game right now...

@Y0ngg4n
Copy link

Y0ngg4n commented Oct 1, 2020

@forslund ok thank you for your engagement ;)

@0vermind
Copy link

I fear only hardware partners with some kind of deal will be admitted. It is always a money game. Sad.
p.s. In the old days, fake the client's ID was the solution but I suppose that there is some kind of cryptographic keys involved now. We can't tell everybody we are "Alexa". :P

@forslund
Copy link
Owner

Yes that's my fear as well. There is a branch which can use user supplied auth info, but I still need to write some docs on how to use it and make it smoother in case Spotify declines again.

@Djinnxie
Copy link

i cant figure out how to use my own key. is there a guide anywhere?

@forslund
Copy link
Owner

forslund commented Oct 30, 2020

EDIT: this method has been added for now into the skill and instructions are available in the readme.md. I leave the old temporary instructions below for completeness but they should not be used anymore.

I quick (and quite dirty) but working way to run spotify with local auth

Set up a developer account and make sure to whitelist https://localhost:8888m then download spauth.py.
Edit it with your client_id, secret and username

go to the mycroft-spotify skill directory and checkout the branch feature/local-api-key

git checkout feature/local-api-key

then in the mycroft-core dir run


pip install -r /opt/mycroft/skills/mycroft-spotify.forslund/requirements.txt

python spauth.py

this should result in a hidden file called .cache-USERNAME

now before starting Mycroft you need to put the client key and client secret in the environment variables

export SPOTIPY_CLIENT_ID=YOUR_CLIENT_ID
export SPOTIPY_CLIENT_SECRET=YOUR_CLIENT_SECRET

Then start Mycroft.

Sorry that I haven't had time to clean this procedure up...

@georgefst
Copy link

Thanks for the guide. Unfortunately that branch doesn't work for me:

 13:17:54.284 | ERROR    | 30275 | SpotifySkill | Couldn't fetch credentials
Traceback (most recent call last):
  File "/opt/mycroft/skills/mycroft-spotify.forslund/__init__.py", line 278, in load_local_creds
    scope=SCOPE)
TypeError: __init__() got an unexpected keyword argument 'username'

This is very odd, since the spotipy docs do show a username argument.

So presumably a versioning issue? I wish I could help, but Python's dependency management has always baffled me.

@georgefst
Copy link

georgefst commented Nov 1, 2020

Also, there's a step missing - you also need to whitelist https://localhost:8888 in the Spotify developer dashboard.

@forslund
Copy link
Owner

forslund commented Nov 1, 2020

Ah humm, yes I think I've updated the spotipy dependency... try running ./bin/mycroft-pip install spotipy==2.14.0 from the mycroft-core folder.

Will add the whitelist step to the description. Thanks for flagging

@georgefst
Copy link

Works, awesome!

Would be a real shame if every user had to fiddle about with a developer account, but at least the option's there for now.

@joshuajaharwood
Copy link

Works, awesome!

Would be a real shame if every user had to fiddle about with a developer account, but at least the option's there for now.

It shouldn't be too bad once you can put your credentials in via Mycroft/Selene. Just a list of instructions to create the app appropriately and some copy-pasting would be needed.

@jpvr555
Copy link

jpvr555 commented Nov 4, 2020

I was able to get it mostly working, I can get it to play and stop on other devices but not on the mycroft itself. Almost like it wasn't registered as a device at all.

@forslund
Copy link
Owner

forslund commented Nov 4, 2020

The skill is not a player in itself, it requires a local player to be installed. Such as librespot or spotifyd (the player needs to be logged in and can't be in discovery mode)

@jpvr555
Copy link

jpvr555 commented Nov 4, 2020

Oh thank you, I miss understood

@joshuajaharwood
Copy link

The skill is not a player in itself, it requires a local player to be installed. Such as librespot or spotifyd (the player needs to be logged in and can't be in discovery mode)

I couldn't see this on the README. May be worth mentioning if not already to prevent future tickets?

@forslund
Copy link
Owner

forslund commented Nov 4, 2020

I have a PR I've forgotten to merge, sorry. It would be helpful if you could read through PR #145 and see if anything should be added

@joshuajaharwood
Copy link

I've left you some feedback on that PR!

@Djinnxie
Copy link

Djinnxie commented Nov 5, 2020

thanks for the update! i cant get it working though. i ran through your guide and it didnt work so i deleted .cache-USERNAME to try again. only now its saying "enter the URL you were redirected to" without giving me a url to enter. i tried unsetting my env variables and running the script in another directory as well as using the URL it provided me last time but no dice. i even tried making another app on the spotify dash. sorry for the trouble
image

@Asheboy
Copy link

Asheboy commented Nov 17, 2020

I'm in the same position as @Djinnxie and just receive the Enter the URL you were redirect to:. I think this is because the white-listing isn't working correctly, but I definitely have the URL set in the developer settings.

EDIT: It might be that spotipy doesn't support headless.

EDIT2: If you install links (sudo apt install links), then that will open the spotify authorisation URL automatically. I used ps aux | grep spotify to find the URL, opened it in a non-headless webbrowser, accepted the authorisation and then provided the URL I got redirected to.

@forslund
Copy link
Owner

Yeah it doesn't do headless it tries to launch a webbrowser. You can run it on a desktop and transfer the files to the target machine.

Thank's for the links tip as well!

@buddens93
Copy link

buddens93 commented Jan 17, 2021

Thanks @forslund !! All working now, appreciate the help 👍

My bad for missing this crucial bit for spauth.py:

then in the mycroft-core dir run

Cheers

@mickenordin
Copy link

mickenordin commented Feb 13, 2021

I ran this on my laptop:

git clone https://github.com/forslund/spotify-skill/
git checkout feature/local-api-key
wget https://gist.githubusercontent.com/forslund/8a2045aaf7c1244d35920c67b3e22930/raw/9ca6931269126be1b1c447558b2d9c067c1b8685/spauth.py
pip install spotipy==2.14.0
~~python3 spauth.py

I am sure i did not need to have the skill on my laptop, but anyway, here we are :) After that I copied the resulting .cache-my_username file to /home/pi/mycroft-core/ on my raspberrypi and then I ran:

mycroft-msm install mycroft-spotify
mycroft-pip install spotipy==2.14.0
cd mycroft-core/skills/mycroft-spotify.forslund/
git checkout feature/local-api-key

I then added the environment variables to .bashrc. After that I rebooted but still I get:

 16:54:39.259 | INFO     |   682 | SpotifySkill | None
 16:54:39.261 | ERROR    |   682 | SpotifySkill | User info has not been set.

In the logfile and Mycroft sais:

I'm not connected to your Spotify account yet. Go to home dot mycroft dot   ai to setup your Spotify skill.

Edit: After adding my username and such to the skill config on home.mycroft.ai it seems I get no errors any more, but I still cant play anything. I get

 17:03:30.877 | INFO     |   681 | SpotifySkill | <mycroft-spotify_forslund.spotify.SpotifyConnect object at 0x852f4370>

And: There are no Spotify devices available. when I ask to list devices. I have several devices on my network including a working raspotify on the raspberrypi

Any pointers?

I actually does seem to work for me now. After playing some stuff from my phone on other devices, mycroft can see the ones I have used, but not the others. Strange, but it seems I am set now atleast.

@forslund
Copy link
Owner

It can only see logged in devices. so if the devices are set to be in discovery mode. After connecting to them using your phone they will be logged in.

What devices are you trying with?

@mickenordin
Copy link

mickenordin commented Feb 16, 2021

What devices are you trying with?

I have some chromecast devices. It works well enough for me with the current mode of operation, I was just surprised that nothing was showing up first :)

@awdel
Copy link

awdel commented Mar 11, 2021

I have been able to successfully connect to Spotify and can use Mycroft to remotely play Spotify songs on my phone but I have been unable to set my Picroft as a device.

When Spotify is not open on my phone and I say "What Spotify devices are available?", Mycroft replies with "There are no Spotify devices available".

I have added my Username and Password to 'Play Spotify' section of my skills, however when I click on the 'Connect' button, it opens a page that simply says 'INVALID_CLIENT: Failed to get client' at the following url:

https://accounts.spotify.com/authorize?client_id=[MYCLIENTID]&redirect_uri=https%3A%2F%2Fapi.mycroft.ai%2Fv1%2Fauth%2Fcallback&scope=user-library-read+streaming+playlist-read-private+user-top-read+user-read-playback-state

Can anyone shed any light on where I am going wrong. Thanks.

@mickenordin
Copy link

I have been able to successfully connect to Spotify and can use Mycroft to remotely play Spotify songs on my phone but I have been unable to set my Picroft as a device.

When Spotify is not open on my phone and I say "What Spotify devices are available?", Mycroft replies with "There are no Spotify devices available".

I have added my Username and Password to 'Play Spotify' section of my skills, however when I click on the 'Connect' button, it opens a page that simply says 'INVALID_CLIENT: Failed to get client' at the following url:

https://accounts.spotify.com/authorize?client_id=[MYCLIENTID]&redirect_uri=https%3A%2F%2Fapi.mycroft.ai%2Fv1%2Fauth%2Fcallback&scope=user-library-read+streaming+playlist-read-private+user-top-read+user-read-playback-state

Can anyone shed any light on where I am going wrong. Thanks.

Hi, I don't think a spotify player is integrated in this skill. If you wish to play music on your raspberry pi you can do what I did and install raspotify on there: https://github.com/dtcooper/raspotify

@awdel
Copy link

awdel commented Mar 11, 2021

Hi, I don't think a spotify player is integrated in this skill. If you wish to play music on your raspberry pi you can do what I did and install raspotify on there: https://github.com/dtcooper/raspotify

Thank you @mickenordin, that was it. The Pi is now showing up as a device and it does try to play the tracks, however there is no sound output to my speakers. I am using a USB DAC with external speakers so I think some tweaking of the output device is required.

@Frederic94220
Copy link

Hello, everyone,
I have the INVALID-Client issue and I tried to understand what all of you guys said here, I have almost no capacities in this domain so is it possible to have some help with my problem or like a complete guide ^^?
I am really sorry to make you guys do all over your explanations again
Thanks for your help in advance!
BTW I'm running a Rasp pi 3 model B ^^

@forslund
Copy link
Owner

Hi @Frederic94220 Above in a comment made the 30th Oct I've provided some instructions. I'm going to try to get a bit more streamlined approach into the skill during next week. (Most is done, just trying to document things).

It won't be perfect but a bit better than following instructions in an issue on github.

@forslund
Copy link
Owner

I've now merged the change to allow local api keys, with a basic helper script and instructions in the readme. Still work to do before it's completely user friendly however.

@Loopinglu
Copy link

Do you mean the readme of the spotify skill? Cause I can't see a change there...
Obviously I have the same problem an tried your instructions @forslund but I despair already at the first one. What shall I do once I have a spotify developer account? What whitelist? And what is a secret? As you may notice, I have no idea about coding but I really want to use the spotify function with my picroft again. I really loved it...
Would be great if one of you could help me out <3

@forslund
Copy link
Owner

forslund commented May 4, 2021

Yes, the steps I've written are here: https://github.com/forslund/spotify-skill#creating-access-token

I'd be happy to get feedback if there are things that are unclear, to improve it :)

@Loopinglu
Copy link

Yes, the steps I've written are here: https://github.com/forslund/spotify-skill#creating-access-token

I'd be happy to get feedback if there are things that are unclear, to improve it :)

Alright, you want feedback @forslund, I hope you don't regret this ;D
I got until

After installing mycroft-spotify, from the mycroft-core folder run the auth.py script in the mycroft-spotify folder

I managed to run source venv-activate.sh but when I tried to run python /opt/mycroft/skills/mycroft-spotify.forslund/auth.py I got this: python: can't open file '/opt/mycroft/skills/mycroft-spotify.forslund/auth.py': [Errno 2] No such file or directory

And it actually does look like the file auth.py does simply not exist. I tried reinstalling mycroft-spotify but that did'nt change it.
Yeah, so that's how far a total amateur aka me got :)

@forslund
Copy link
Owner

forslund commented May 9, 2021

Thanks, I must add a note that this hasn't been released to the mainline (there will currently be some conflicts with the Mark-1 install until the next release of core). Currently you need to ask Mycroft to install the beta version of the skill (or use the -l flag with msm), or install it manually.

@JesusCendejas
Copy link

hello, good morning, sorry, when I try to configure my spotify account in mycroft, a page appears saying INVALID_CLIENT: Failed to get client, how can I fix it?

@forslund
Copy link
Owner

Hi @JesusCendejas, sorry for the delay in answering. Currently you need to install the beta version of the skill, you should be able to say "Hey mycroft, install the beta version of the spotify skill". Then you need to follow the instructions from the readme here: https://github.com/forslund/spotify-skill#authorization

Let me know if you get stuck some where and we'll try to improve the instructions

@arkadiy-telegin
Copy link

Hey @forslund, after downloading the beta version of the skill and following the guide in README.md, I still get an error. After I put my username and password into the corresponding fields at account.mycroft.ai/skills, I get the following message:

INVALID_CLIENT: Failed to get client

@forslund
Copy link
Owner

Where do you get that, is it the skill log or is it when running the auth script?

Another thing that may be of interest, what platform is this on?

@arkadiy-telegin
Copy link

auth.py finishes successfully, after that (according to README.md) one has to add the account into the skill settings at https://account.mycroft.ai/skills. This is the step where the setup fails. After saving the configuration and pressing the "Connect" button, INVALID_CLIENT: Failed to get client is returned by the webpage.

I have my mycroft running in docker.

@forslund
Copy link
Owner

Ok, something is off, after the update there should be no Connect button on the skills page. Can you verify that the skill starts successfully by either using the :skills command in the mycroft-cli (if the skill is red it hasn't loaded correctly) or asking Mycroft "what spotify devices are available" (he should reply with something about missing credentials).

Also if you have several installs there may be tabs on the skill page with multiple versions of the spotify skill

@JesusCendejas
Copy link

@forslund Thank you very much. The truth is that I was able to register the spotify account, however when I ask What Spotify devices are available? mycroft returns There are no Spotify devices available, just like when I say some command like Play Hello Nasty on Spotify it prints I'm not sure how to play Play Hello Nasty on Spotify, how can I fix it? good evening

@forslund
Copy link
Owner

The problem may be that there is no spotify-connect enabled player set up? The skill is not a player on it's own, instead it uses the spotify-connect api to start playback on detected devices (they need to be logged in with user / password...see readme). It was developed with librespot and the Spotify desktop-client as reference devices.

@Maxibraeu
Copy link

Maxibraeu commented Jul 24, 2022

Hello @forslund
I read through your intructions and then tried to run the spauth.py, but when I enter the url I was redirected to I get the following error:

  File "spauth.py", line 13, in <module>
    sp = spotipy.Spotify(auth_manager=am)
TypeError: __init__() got an unexpected keyword argument 'auth_manager'

I would be really greatful for any help

@forslund
Copy link
Owner

forslund commented Jul 24, 2022

Hi @Maxibraeu, the instructions here are a bit dated. please checkout the default branch (21.02) and follow the instructions in the readme.md here.

Since you've switched branches back and forth the incorrect version of spotipy may be installed. So you might need to run something like

source venv-activate.sh
mycroft-pip install -r /opt/mycroft/skills/mycroft-spotify.forslund/requirements.txt

Let me know how you get along with that and I'll try to help you further if you get stuck.

@Maxibraeu
Copy link

Maxibraeu commented Jul 27, 2022

Hi @forslund its me again,first thanks for your quick response. I tried to do the new installation but failed on following error while installing raspotify.
After I did
sudo apt install raspotify
following error ocurred

 raspotify : Depends: libc6 (>= 2.31) but 2.28-10+rpt2+rpi1+deb10u1 is to be ins                                                                                                                                                             talled
             Depends: libasound2 (>= 1.2.4)
             Depends: alsa-utils (>= 1.2.4) but 1.1.8-2+rpt1 is to be installed
             Depends: libpulse0 (>= 14.2) but 12.2-4+deb10u1+rpt3 is to be installed                                                                                                                                                          
             Depends: systemd (>= 247.3) but 241-7~deb10u8+rpi1 is to be installed                                                                                                                                                          
             Depends: init-system-helpers (>= 1.60) but 1.56+nmu1 is to be installed                                                                                                                                                          
E: Unable to correct problems, you have held broken packages.

but if I search for example libc6 there is no version 2.31

Thanks for help

@forslund
Copy link
Owner

@Maxibraeu sorry for the late response. I've been away for a couple of days. Can you tell me what system you're running on?

Assuming that it's the picroft you're using: It could be that Raspotify has switch to the latest Debian Bullseye as target for their build and the picroft is still based on the old Debian Buster. I shall test this and see if I can do a custom build and provide a repo for the picroft.

@Maxibraeu
Copy link

@forslund you are completely right. I am using Picroft and it would be really nice if you could make a custom build and provide a repo. Thank you very much. 😃

@forslund
Copy link
Owner

@Maxibraeu sorry for the long response time. I haven't gotten around to creating a debian repo of my own but I checked my version and you can download the deb from this github tag: https://github.com/dtcooper/raspotify/releases/tag/0.31.3

My guess is that all 0.31.x releases will work.

@Maxibraeu
Copy link

Maxibraeu commented Aug 18, 2022

Hi @forslund thanks for you anwer, I installed your version of Raspotify and then found all files from your description , but when I was going on and then finaly tried to use the Skill there was an Error again wich looked like this:

play never gonna give you up on spotify                    
 >> Just a second                                           
 >> Unable to authorize with the Spotify service. Please
    go to Skill settings at home dot mycroft dot ai to
    verify your username and password and to Connect to                                                     
    Spotify.

And when I do What he says I get the same Error. But I got an Email from Spotify that a new device has logged into my account

Thaks for your Help. 😄

@Maxibraeu
Copy link

Maxibraeu commented Aug 18, 2022

@forslund Its me again I saw that I used the wrong username and now its working thanks for all you help during the last weeks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests