Spotify music_service search fails - AuthTokenExpired #428

Closed
Zolmeister opened this Issue Aug 30, 2016 · 19 comments

Comments

Projects
None yet
@Zolmeister

Seems simple enough, am I doing something incorrectly?

from soco import SoCo
from soco.music_services import MusicService

device = SoCo("x.x.x.x")
service = MusicService('Spotify')
service.search(category='tracks', term='pinball')
Traceback (most recent call last):
  File "soco-0.11.1-py3.5.egg/soco/music_services/music_service.py", line 151, in call
  File "soco-0.11.1-py3.5.egg/soco/soap.py", line 310, in call
soco.soap.SoapFault: s:Client.AuthTokenExpired: AuthTokenExpired

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sonos.py", line 10, in <module>
    service.search(category='tracks', term='pinball')
  File "soco-0.11.1-py3.5.egg/soco/music_services/music_service.py", line 715, in search
  File "soco-0.11.1-py3.5.egg/soco/music_services/music_service.py", line 182, in call
soco.exceptions.MusicServiceException: ('AuthTokenExpired', 's:Client.AuthTokenExpired')

And changing Spotify to Google Play Music

Traceback (most recent call last):
  File "sonos.py", line 10, in <module>
    service.search(category='tracks', term='pinball')
  File "soco-0.11.1-py3.5.egg/soco/music_services/music_service.py", line 715, in search
  File "soco-0.11.1-py3.5.egg/soco/music_services/music_service.py", line 146, in call
  File "soco-0.11.1-py3.5.egg/soco/music_services/music_service.py", line 111, in get_soap_header
  File "soco-0.11.1-py3.5.egg/soco/services.py", line 181, in _dispatcher
  File "soco-0.11.1-py3.5.egg/soco/services.py", line 408, in send_command
  File "soco-0.11.1-py3.5.egg/soco/services.py", line 469, in handle_upnp_error
soco.exceptions.SoCoUPnPException: UPnP Error 8009 received:  from x.x.x.x
@KennethNielsen

This comment has been minimized.

Show comment
Hide comment
@KennethNielsen

KennethNielsen Sep 5, 2016

Member

Hallo @Zolmeister and thanks for reporting this.

@lawrenceakka do you have any input on this?

Member

KennethNielsen commented Sep 5, 2016

Hallo @Zolmeister and thanks for reporting this.

@lawrenceakka do you have any input on this?

@tfriedel

This comment has been minimized.

Show comment
Hide comment
@tfriedel

tfriedel Oct 3, 2016

I have the same problem. With SoundCloud too. TuneIn works though.

tfriedel commented Oct 3, 2016

I have the same problem. With SoundCloud too. TuneIn works though.

@jrathert

This comment has been minimized.

Show comment
Hide comment
@jrathert

jrathert Oct 29, 2016

Same problem here with any relevant call to a Spotify-service. E.g. I do
spotify = MusicService('Spotify')
spotify.search(category='tracks', term='pinball')
meta = spotify.get_media_uri("spotify:track:7HFaTkpIeG0pXINEm7EEG4")
and both calls (search, get_media_uri) fail with the error above.

Although a bit experienced with programming and using PyCharm, I am not able to fully understand that.

jrathert commented Oct 29, 2016

Same problem here with any relevant call to a Spotify-service. E.g. I do
spotify = MusicService('Spotify')
spotify.search(category='tracks', term='pinball')
meta = spotify.get_media_uri("spotify:track:7HFaTkpIeG0pXINEm7EEG4")
and both calls (search, get_media_uri) fail with the error above.

Although a bit experienced with programming and using PyCharm, I am not able to fully understand that.

@KennethNielsen

This comment has been minimized.

Show comment
Hide comment
@KennethNielsen

KennethNielsen Oct 29, 2016

Member

Hi guys.

We are seeing a lot of this right now for a large number of music services. My guess (which or more or less specifically mentioned in the traceback of the errors) is that one of the ways Sonos does music service authentication has changed and tha basically all the music services that authenticate that way therefore fails.

If someone wants to help and is up for some internet searching, it is possible that there is already information about this in the Sonos community or with one of the other Sonos driver implementations.

Member

KennethNielsen commented Oct 29, 2016

Hi guys.

We are seeing a lot of this right now for a large number of music services. My guess (which or more or less specifically mentioned in the traceback of the errors) is that one of the ways Sonos does music service authentication has changed and tha basically all the music services that authenticate that way therefore fails.

If someone wants to help and is up for some internet searching, it is possible that there is already information about this in the Sonos community or with one of the other Sonos driver implementations.

@lawrenceakka

This comment has been minimized.

Show comment
Hide comment
@lawrenceakka

lawrenceakka Nov 6, 2016

Contributor

Yup - the authentication methods have changed. I'm on it!

Contributor

lawrenceakka commented Nov 6, 2016

Yup - the authentication methods have changed. I'm on it!

@jandebeule

This comment has been minimized.

Show comment
Hide comment
@jandebeule

jandebeule Dec 20, 2016

@lawrenceakka : do you have any update on this issue?

@lawrenceakka : do you have any update on this issue?

@Hackerjoe

This comment has been minimized.

Show comment
Hide comment
@Hackerjoe

Hackerjoe Dec 22, 2016

@lawrenceakka Also have same issue. Any news?

@lawrenceakka Also have same issue. Any news?

@janbar janbar referenced this issue in janbar/noson-app Jan 7, 2017

Closed

Spotify support #7

@cfrauenberger

This comment has been minimized.

Show comment
Hide comment
@cfrauenberger

cfrauenberger Jan 13, 2017

Exact same problem with Spotify - happy to help @lawrenceakka in terms of testing / researching etc.

Thanks for looking into it!

Exact same problem with Spotify - happy to help @lawrenceakka in terms of testing / researching etc.

Thanks for looking into it!

@HughMacdonald

This comment has been minimized.

Show comment
Hide comment
@HughMacdonald

HughMacdonald Feb 4, 2017

Just wanted to add a "me too" - just started playing with SoCo, and can't get it to search Spotify. Commenting to ensure I get a notification when there's an update from @lawrenceakka

Just wanted to add a "me too" - just started playing with SoCo, and can't get it to search Spotify. Commenting to ensure I get a notification when there's an update from @lawrenceakka

@JochenPfeifferHD

This comment has been minimized.

Show comment
Hide comment
@JochenPfeifferHD

JochenPfeifferHD Mar 26, 2017

Hi it is the same for me. Any News on this?

Hi it is the same for me. Any News on this?

@lawrenceakka

This comment has been minimized.

Show comment
Hide comment
@lawrenceakka

lawrenceakka Mar 26, 2017

Contributor

Time for an update - sorry for the long silence 😁

Sonos has changed the way in which music service account data can be accessed. It used to be possible to get the necessary info from the players, but it is now encrypted using AES-CBC. Although other third party Sonos controllers have worked out how to get round this and decrypt the info (see here for a discussion), I am not sure that it would be right for us to do so in an open source project (though I haven't decided yet).

BUT:

I have today managed to successfully register a python soco script with Google Play Music. The script requires user interaction (you have to go to a web page and input your Google Play credentials). It may therefore be possible to create a workaround where you run a registration script and then use the returned details to allow SoCo to use third party media services. I suppose the details will change from time to time so it might be necessary to run the registration script again.

Research continues ....

Contributor

lawrenceakka commented Mar 26, 2017

Time for an update - sorry for the long silence 😁

Sonos has changed the way in which music service account data can be accessed. It used to be possible to get the necessary info from the players, but it is now encrypted using AES-CBC. Although other third party Sonos controllers have worked out how to get round this and decrypt the info (see here for a discussion), I am not sure that it would be right for us to do so in an open source project (though I haven't decided yet).

BUT:

I have today managed to successfully register a python soco script with Google Play Music. The script requires user interaction (you have to go to a web page and input your Google Play credentials). It may therefore be possible to create a workaround where you run a registration script and then use the returned details to allow SoCo to use third party media services. I suppose the details will change from time to time so it might be necessary to run the registration script again.

Research continues ....

@relevitt

This comment has been minimized.

Show comment
Hide comment
@relevitt

relevitt Mar 26, 2017

Contributor

Thanks for update. I use Sonos to listen to Spotify (plus downloaded music) and the Spotify API for searches. The main drawback of the change is I can't access Spotify Radio via SoCo.

Contributor

relevitt commented Mar 26, 2017

Thanks for update. I use Sonos to listen to Spotify (plus downloaded music) and the Spotify API for searches. The main drawback of the change is I can't access Spotify Radio via SoCo.

@ghcs27

This comment has been minimized.

Show comment
Hide comment
@ghcs27

ghcs27 Mar 27, 2017

Member

Now that it's confirmed that this problem pertains to all music services, I'd suggest making one issue for all problems arising from the account data encryption, and closing all the individual issues (#433, #446, #451) since it's better to have all the information in one place.

Member

ghcs27 commented Mar 27, 2017

Now that it's confirmed that this problem pertains to all music services, I'd suggest making one issue for all problems arising from the account data encryption, and closing all the individual issues (#433, #446, #451) since it's better to have all the information in one place.

@KennethNielsen

This comment has been minimized.

Show comment
Hide comment
@KennethNielsen

KennethNielsen Mar 27, 2017

Member

@ghcs27 it is not all music services. I have a few running that works just fine. As I understand it, it is restricted to those that use OAuth authentication (@lawrenceakka right?) , most significantly Google Play Music and Spotify.

I think a common issue is a good idea, but we should make sure to get the description right.

Member

KennethNielsen commented Mar 27, 2017

@ghcs27 it is not all music services. I have a few running that works just fine. As I understand it, it is restricted to those that use OAuth authentication (@lawrenceakka right?) , most significantly Google Play Music and Spotify.

I think a common issue is a good idea, but we should make sure to get the description right.

@jhaals

This comment has been minimized.

Show comment
Hide comment
@jhaals

jhaals Aug 10, 2017

Hi, any updates on this issue?

jhaals commented Aug 10, 2017

Hi, any updates on this issue?

@jeantristan

This comment has been minimized.

Show comment
Hide comment
@jeantristan

jeantristan Sep 9, 2017

Got the same issue here too

Got the same issue here too

@KennethNielsen

This comment has been minimized.

Show comment
Hide comment
@KennethNielsen

KennethNielsen Sep 18, 2017

Member

@ghcs27 I do however support the idea of making a meta issue. Do you want to formulate it.

I also think, that we should add something in large bold red letters to the github frontpage, which clearly states, that the issue with these services is due to Sonos changing the authentication method to something that open source projects cannot access and that if people want that to change, they should bug Sonos, not us. I think maybe I will do a PR for that.

Member

KennethNielsen commented Sep 18, 2017

@ghcs27 I do however support the idea of making a meta issue. Do you want to formulate it.

I also think, that we should add something in large bold red letters to the github frontpage, which clearly states, that the issue with these services is due to Sonos changing the authentication method to something that open source projects cannot access and that if people want that to change, they should bug Sonos, not us. I think maybe I will do a PR for that.

@estwanick

This comment has been minimized.

Show comment
Hide comment
@estwanick

estwanick Jan 1, 2018

Experiencing the same issue when calling get_metadata() on Apple Music

Experiencing the same issue when calling get_metadata() on Apple Music

@KennethNielsen

This comment has been minimized.

Show comment
Hide comment
@KennethNielsen

KennethNielsen Jan 6, 2018

Member

Closing this issue in favor of #557 to gather information in one place.

Member

KennethNielsen commented Jan 6, 2018

Closing this issue in favor of #557 to gather information in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment