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

403 Forbidden when playing a song #220

Open
aplocher opened this issue May 26, 2018 · 15 comments
Open

403 Forbidden when playing a song #220

aplocher opened this issue May 26, 2018 · 15 comments

Comments

@aplocher
Copy link
Contributor

Hello, I had my Echo Dot turned off for the last month or so. I've recently plugged it back in and now when I go to use GeeMusic I'm receiving a 403-forbidden error from Google when it tries to start the stream.

Listing my playlists and other non-song-playing commands seem to work just fine.

Anyone know why? Was there a recent update to the code that I need to grab?

Everything was working fine last time I used it (like a month or so ago), but now it's not working. I last git-pulled and built geemusic I think in February, so it's not too terribly old.

I've pasted the output that I got from Foreman below...

Thank you!

16:25:11 web.1  | 127.0.0.1 - - [26/May/2018 16:25:11] "POST /alexa HTTP/1.0" 200 -
16:25:12 web.1  | 127.0.0.1 - - [26/May/2018 16:25:12] "HEAD /alexa/stream/Tr56ue23f5fe5jmxdkzlkxia4ta HTTP/1.0" 500 -
16:25:12 web.1  | 127.0.0.1 - - [26/May/2018 16:25:12] "GET /alexa/stream/Tr56ue23f5fe5jmxdkzlkxia4ta HTTP/1.0" 500 -
16:25:13 web.1  | Traceback (most recent call last):
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
16:25:13 web.1  |     return self.wsgi_app(environ, start_response)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
16:25:13 web.1  |     response = self.handle_exception(e)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
16:25:13 web.1  |     reraise(exc_type, exc_value, tb)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
16:25:13 web.1  |     raise value
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
16:25:13 web.1  |     response = self.full_dispatch_request()
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
16:25:13 web.1  |     rv = self.handle_user_exception(e)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
16:25:13 web.1  |     reraise(exc_type, exc_value, tb)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
16:25:13 web.1  |     raise value
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
16:25:13 web.1  |     rv = self.dispatch_request()
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
16:25:13 web.1  |     return self.view_functions[rule.endpoint](**req.view_args)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/geemusic/controllers.py", line 12, in redirect_to_stream
16:25:13 web.1  |     stream_url = api.get_google_stream_url(song_id)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/geemusic/utils/music.py", line 148, in get_google_stream_url
16:25:13 web.1  |     return self._api.get_stream_url(song_id)
16:25:13 web.1  |   File "<decorator-gen-102>", line 2, in get_stream_url
16:25:13 web.1  |     
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/gmusicapi/utils/utils.py", line 293, in wrapper
16:25:13 web.1  |     return function(*args, **kw)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/gmusicapi/clients/mobileclient.py", line 388, in get_stream_url
16:25:13 web.1  |     return self._make_call(mobileclient.GetStreamUrl, song_id, device_id, quality)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/gmusicapi/clients/shared.py", line 84, in _make_call
16:25:13 web.1  |     return protocol.perform(self.session, self.validate, *args, **kwargs)
16:25:13 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/gmusicapi/protocol/shared.py", line 226, in perform
16:25:13 web.1  |     raise CallFailure(err_msg, call_name)
16:25:13 web.1  | gmusicapi.exceptions.CallFailure: GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?opt=hi&net=mob&pt=e&slt=1527377112170&sig=LEpFLXj_P1hzseOAZKZ6KwrOtM4&mjck=Tr56ue23f5fe5jmxdkzlkxia4ta&hl=en_US&dv=0&tier=aa
16:25:13 web.1  | (requests kwargs: {'method': 'GET', 'url': 'https://mclients.googleapis.com/music/mplay', 'allow_redirects': False, 'headers': {'X-Device-ID': '989096C1DAAD', 'Authorization': '<omitted>'}, 'params': {'opt': 'hi', 'net': 'mob', 'pt': 'e', 'slt': '1527377112170', 'sig': b'LEpFLXj_P1hzseOAZKZ6KwrOtM4', 'mjck': 'Tr56ue23f5fe5jmxdkzlkxia4ta', 'hl': 'en_US', 'dv': 0, 'tier': 'aa'}})
16:25:13 web.1  | (response was: '<HTML>\n<HEAD>\n<TITLE>Forbidden</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Forbidden</H1>\n<H2>Error 403</H2>\n</BODY>\n</HTML>\n')
16:25:13 web.1  | 127.0.0.1 - - [26/May/2018 16:25:13] "HEAD /alexa/stream/Tr56ue23f5fe5jmxdkzlkxia4ta HTTP/1.0" 500 -
16:25:13 web.1  | 127.0.0.1 - - [26/May/2018 16:25:13] "GET /alexa/stream/Tr56ue23f5fe5jmxdkzlkxia4ta HTTP/1.0" 500 -


@fergyfresh
Copy link
Collaborator

fergyfresh commented May 27, 2018 via email

@edjbush
Copy link

edjbush commented May 27, 2018

Sorry - I am fairly new to this and don't have a good python background. I have set this up tp run on Heroku and things were fine until a couple of days ago. Seem to have been experiencing the same "Forbidden" error. Unfortunately, i don't understand the comment about finding a valid device id. Did something change with the google interface? As described above all non-streaming commands work fine. Thanks! Below is the last lines form the Heroku log:

2018-05-27T01:28:01.603306+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gmusicapi/utils/utils.py", line 293, in wrapper
2018-05-27T01:28:01.603309+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gmusicapi/clients/mobileclient.py", line 388, in get_stream_url
2018-05-27T01:28:01.603310+00:00 app[web.1]: return self._make_call(mobileclient.GetStreamUrl, song_id, device_id, quality)
2018-05-27T01:28:01.603311+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gmusicapi/clients/shared.py", line 84, in _make_call
2018-05-27T01:28:01.603315+00:00 app[web.1]: return protocol.perform(self.session, self.validate, *args, **kwargs)
2018-05-27T01:28:01.603316+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gmusicapi/protocol/shared.py", line 226, in perform
2018-05-27T01:28:01.603317+00:00 app[web.1]: raise CallFailure(err_msg, call_name)
2018-05-27T01:28:01.603319+00:00 app[web.1]: gmusicapi.exceptions.CallFailure: GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?opt=hi&net=mob&pt=e&slt=1527384481495&sig=xJ8iIyYfpfBnMb6-8e87KxTTdtM&mjck=Tkt2j6a6rfpeqpn7sgrkn45k6fu&hl=en_US&dv=0&tier=aa
2018-05-27T01:28:01.603321+00:00 app[web.1]: (requests kwargs: {'method': 'GET', 'url': 'https://mclients.googleapis.com/music/mplay', 'allow_redirects': False, 'headers': {'X-Device-ID': '1640054800FD', 'Authorization': ''}, 'params': {'opt': 'hi', 'net': 'mob', 'pt': 'e', 'slt': '1527384481495', 'sig': b'xJ8iIyYfpfBnMb6-8e87KxTTdtM', 'mjck': 'Tkt2j6a6rfpeqpn7sgrkn45k6fu', 'hl': 'en_US', 'dv': 0, 'tier': 'aa'}})
2018-05-27T01:28:01.603322+00:00 app[web.1]: (response was: '\n\n<TITLE>Forbidden</TITLE>\n\n\n

Forbidden

\n

Error 403

\n\n\n')

@fergyfresh
Copy link
Collaborator

fergyfresh commented May 27, 2018 via email

@aplocher
Copy link
Contributor Author

@fergyfresh thanks, what command are you referring to? I don't see mention of a command.

When I was googling this particular error I did see several folks mention it over in the gmusicapi repo, and the fix was always device-id-related, however as far as I know there's no configurable device-id in geemusic - at least it doesn't mention it in the docs that I've seen.

I did try a new app password, thinking that maybe authenticating for the first time with an app-password (when using 2-factor auth) somehow initialized a device id or something. But that didn't help at all.

@edjbush thanks, glad to know I'm not the only one lol...

@starostin
Copy link

Hi guys, I am facing the same issue today

@fergyfresh
Copy link
Collaborator

fergyfresh commented May 27, 2018 via email

@aplocher
Copy link
Contributor Author

aplocher commented May 27, 2018

@fergyfresh Thank you that was helpful. Here's the steps I went through to fix it:

  • Editted my .env file (the one with all the config values for geemusic)
  • Added a line like: ANDROID_ID=HEYBUDDY (note, HEYBUDDY is intentionally invalid, reason below)
  • Went to start foreman, but it will fail right away with a list of your device IDs (there's probably a better way to do this...)
$ foreman start
13:41:02 web.1  | started with pid 5587
13:41:10 web.1  | Traceback (most recent call last):
13:41:10 web.1  |   File "server.py", line 1, in <module>
13:41:10 web.1  |     from geemusic import app
13:41:10 web.1  |   File "/home/adam/src/geemusic-new/geemusic/geemusic/__init__.py", line 26, in <module>
13:41:10 web.1  |     api = GMusicWrapper.generate_api(logger=app.logger)
13:41:10 web.1  |   File "/home/adam/src/geemusic-new/geemusic/geemusic/utils/music.py", line 267, in generate_api
13:41:10 web.1  |     **kwargs)
13:41:10 web.1  |   File "/home/adam/src/geemusic-new/geemusic/geemusic/utils/music.py", line 14, in __init__
13:41:10 web.1  |     success = self._api.login(username, password, environ.get('ANDROID_ID', Mobileclient.FROM_MAC_ADDRESS))
13:41:10 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/gmusicapi/clients/mobileclient.py", line 143, in login
13:41:10 web.1  |     self.android_id = self._validate_device_id(device_id, is_mac=is_mac)
13:41:10 web.1  |   File "/home/adam/src/geemusic-new/geemusic/.vnee/lib/python3.6/site-packages/gmusicapi/clients/mobileclient.py", line 58, in _validate_device_id
13:41:10 web.1  |     raise InvalidDeviceId('Invalid device_id %s.' % device_id, devices)
13:41:10 web.1  | gmusicapi.exceptions.InvalidDeviceId: Invalid device_id HEYBUDDY.Your valid device IDs are:
13:41:10 web.1  | * 37b1
13:41:10 web.1  | * 9890
13:41:10 web.1  | * 3f39
13:41:10 web.1  | * 3c61
13:41:10 web.1  | * e49f
13:41:10 web.1  | * 3824
13:41:10 web.1  | * 6067
13:41:10 web.1  | * 68A3
13:41:10 web.1  | * 0022
13:41:11 web.1  | exited with code 1

(note, I truncated the actual device IDs for .. uh.. security I guess - they will be much longer IDs)

  • Edit your .env file again
  • Change the ANDROID_ID to a valid one from the list. Try the first ID in your "valid IDs" list. I suppose if it still fails, try the next one until it doesn't fail. Mine worked right away with the first one listed.

@fergyfresh
Copy link
Collaborator

fergyfresh commented May 27, 2018 via email

@edjbush
Copy link

edjbush commented May 27, 2018

Thanks @aplocher !

You can do the same type of process with Heroku. Edit the Heroku input variables under the Settings Tab to include ANDROID_ID=HEYBUDDY (I just used the same dummy ID). Then after the program fails go to the Heroku activity logs in the pulldown "More" menu and there will be a list of 16 character IDs. I just chose one and it is streaming again.

@starostin
Copy link

I had 3 ID in the list (all from iOS devices). But no one worked for me. Thankfully I have android device which I am not already using. So I opened google music on it, than tried to do the same steps, added real android device id and now everything works!. Thanks a lot.

@chasedixon
Copy link

I was having the same issue, this fixed it! Thank you!

@Bronskiy
Copy link

It it allow 12char ids?

@fergyfresh
Copy link
Collaborator

@Bronskiy it appears as if it doesn't. The old style way of using MAC Addresses to generate the Device ID appears to be quite finicky. If you have any computers that can play music from Google Play try this.

from gmusicapi import Mobileclient

email = "[email protected]"
app_pw = "myrandomapppassword"

api = Mobileclient.login(email, app_pw, Mobileclient.FROM_MAC_ADDRESS)

my_registered_devices = api.get_registered_devices()

If you look through the my_registered_devices and try to find one that says ANDROID_ID you might be able to get in there. Otherwise, you'll have to bring it up here https://github.com/simon-weber/gmusicapi

@Bronskiy
Copy link

Also if anyone who didn't use android devices with google music before then you can use one of android emulators like Nox, Genymotion(trial) or AndY. Just login with your google account and run g.music app and try to start any track. Then new device id will appear in your 'valid device IDs' so you can use it in geemusic.
FYI: my problem is solved now. Thanks to everyone.

@adadkins
Copy link

adadkins commented Jan 9, 2020

I'm also running into this issue. I only have IOS and PC devices. Do you absolutely need an android id for this to work? I'm able to log in with an app specific password for instance the success = self._api.login is a success with a PC or IOS id, but I'm getting an issue with actually streaming music, which i think is caused by the call not having authorization ie Authorization': 'omitted' .

gmusicapi.exceptions.CallFailure: GetStreamUrl: 403 Client Error: Forbidden for url: https://mclients.googleapis.com/music/mplay?opt=hi&net=mob&pt=e&slt=1578542451332&sig=eXp-g0Foi1UeYIEazw05uKNFfQA&mjck=T4qimilrtjxqqhkwnnayaito3su&hl=en_US&dv=0&tier=aa
04:00:54 web.1 | (requests kwargs: {'method': 'GET', 'url': 'https://mclients.googleapis.com/music/mplay', 'allow_redirects': False, 'headers': {'X-Device-ID': 'f43d95c81a5254ef6603b8438526acc21a83ce3a0c7f87c1438df618df0e0476', 'Authorization': ''}, 'params': {'opt': 'hi', 'net': 'mob', 'pt': 'e', 'slt': '1578542451332', 'sig': b'eXp-g0Foi1UeYIEazw05uKNFfQA', 'mjck': 'T4qimilrtjxqqhkwnnayaito3su', 'hl': 'en_US', 'dv': 0, 'tier': 'aa'}})

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

No branches or pull requests

7 participants