Mopidy-Gmusic not authenticating

I’ve been trying for about 2 hours now to get Google Music support working.

The main Mopidy log shows this -

2015-05-26 20:16:36,748 - INFO Starting Mopidy core
2015-05-26 20:16:37,793 - DEBUG ClientLogin()
2015-05-26 20:16:37,843 - INFO Starting new HTTPS connection (1): www.google.com
2015-05-26 20:16:38,510 - DEBUG “POST /accounts/ClientLogin HTTP/1.1” 404 65
2015-05-26 20:16:38,562 - INFO failed to authenticate
2015-05-26 20:16:38,565 - ERROR Failed to login as "MYGoogleUSERNAME"
2015-05-26 20:16:38,572 - INFO Start refreshing Google Music library
2015-05-26 20:16:38,575 - INFO Loaded 0 playlists from Google Music

The gmusicapi log shows this -

!-- begin debug log --!
version: 4.1.0-dev
logging to: /home/mopidy/.cache/gmusicapi/log/gmusicapi.log
2015-05-26 20:16:35,872 - gmusicapi.Mobileclient1 (shared:70) [INFO]: initialized
2015-05-26 20:16:35,880 - gmusicapi.Mobileclient1 (shared:93) [INFO]: logged out
2015-05-26 20:16:37,793 - gmusicapi.Mobileclient1 (shared:204) [DEBUG]: ClientLogin()
2015-05-26 20:16:38,562 - gmusicapi.Mobileclient1 (mobileclient:41) [INFO]: failed to authenticate

I previously had the ‘Access for less secure apps’ - ‘Turned Off’ but received the emails saying the logins were being blocked and so set it to ‘Turned On’.

The main log suggests that the login request returns a HTTP status 404.

If you go directly to www.google.com/accounts/ClientLogin you also will get a 404 with it showing the text link developers.google.com/accounts/docs/AuthForInstalledApps

Has anybody recently got Pi Musicbox 6 working with Google Music?

I’m having the same problem with two Mopidy installations. Mopidy-GMusic had been working fine for several weeks. When I restarted one of my Mopidy servers for an unrelated issue yesterday it said that it could not authenticate my Gmusic account. I restarted my second Mopidy server and had the same result. So something has changed in the last few days. If anyone has ideas, I’m all ears!

Thanks,
Aaron

This is basically because Google have stopped supporting the sign in method that gmusic-mopidy uses.

I’ve raised an issue here - https://github.com/hechtus/mopidy-gmusic/issues/87

It will be broken until the gmusic plugin is updated

I got it working with my raspberrypi musicbox installation, but it wasn’t easy and I’m not sure if I’d recommend it. But for anyone who’s desperate to get this working…

Step 0) please make a backup of your SD card…

  1. ssh in, install python-dev (I used apt-get). Edit: you’ll also need to install build-essential
  2. install the latest gmusicapi dev version (I used PIP with the gmusicapi zip file download on github)
  3. backup and then edit /usr/local/lib/python2.7/dist-packages/mopidy_gmusic/session.py
    3a) somewhere around line 21, you’ll need to add “test”(or any string in quotes) so that the line looks like this:
if not self.api.login(username, password, "test"):

3b) further down the file change the get_thumbs_up_songs method to look like this:

def get_thumbs_up_songs(self):
    return {}
  1. reboot the raspi
  2. wait a few minutes and see if gmusic is running. I can browse, search, see playlists, and play music from the gmusic extension.

I know almost nothing about these changes and have no idea what the side effects may be. I’ve only been using it for about 5 minutes and it seems to work. Also, I would imagine the “get_thumbs_up_songs” functionality doesn’t work now. Not sure I ever used it before.

Aaron

The test variable you passed in the login function is supposed to be your android ID, thanks for the steps though, I was planning on doing this tonight, I’d already put the dev branch of the api on my previous music box image but then messed something up so was going to start again

Thanks. Yeah, I saw that mentioned in one of the threads you lead me to above. I have no idea what “Android ID” is or what it’s used for, but it seems any string will do.

The steps I described above don’t really reflect all the troubleshooting I did, but I think if you install python-dev first, then everything should work with those steps. I had some trouble with the Crypto dependency when installing gmusicapi, but I think it should install cleanly (automatically) if you install python-dev first. Good luck.

In the mopidy config for the Google Music access, it asks for username password and android device ID,

the line 21 should be changed to

if not self.api.login(username, password, deviceid):

I’ve now got it working as well, but I needed to do

apt-get install python-crypto

even after installing the python-dev package as there was still the warning about not having the crypto.publickey package

There are still some warnings popping up in the mopidy.log file related to the SSL connection being made to Google but it is at least working!

Thanks again for the input Aaron

Edit: Whoops, read your post too quickly. You’re all set! But for anyone else looking to do this:

Not sure if you caught it in time, but I edited my steps to include both python-dev AND build-essential (both using apt-get install). I think if you install build-essential and then try to install gmusicapi again, it will work. Crypto was what I got hung up on too, and I’m pretty sure it’ll automatically install with gmusicapi if you install build-essential first. Give it a shot!

PS: I just had to do all of this again after I made the unfortunate decision to attempt to update mopidy-mopify (alternate web interface) and had to start from scratch.

I’ve also just had to do it all over again after updating mopidy-moped which also force updated mopidy >.<

I managed to get it all working with just the following -

apt-get install python-crypto

wget https://github.com/simon-weber/Unofficial-Google-Music-API/archive/develop.zip

pip install --upgrade develop.zip

reboot

and then doing the edits to line 21 and 69 as mentioned in the above post

1 Like

I tried the suggested modification to
/usr/local/lib/python2.7/dist-packages/mopidy_gmusic/session.py

But mopidy dies with an exception (below). If I revert back to the original session.py, mopidy runs but I don’t authenticate with google play.

File “/usr/lib/python2.7/dist-packages/pykka/actor.py”, line 437, in tell
raise _ActorDeadError(’%s not found’ % self)
ActorDeadError: GMusicBackend (urn:uuid:3336ef37-1df9-4244-b97b-63edc507ce9a) not found

Hi, what changes did you do exactly? Can you paste your session file contents from lines 21 and 68+69?

Hi fusen,
I only made the change on line 21. Let me check the others lines (68+69).

What should I expect to see at 68+69? In my session.py file, 68 is empty and 69 is :
def get_deviceid(self, username, password): Do I need the python-dev package installed?

I’m having the same problem as wilberking. I made all the changes described by Aaron and it looks like adding the deviceid to line 21 adds an extra argument to login thats causing the problem…I tried updating the mopidy-gmusic extension but that made musicbox not work as expected…not sure exactly what i’m doing and i’m exhausted…any thoughts? Logs bellow…

ERROR Unhandled exception in GMusicBackend (urn:uuid:074b7cf6-6b2c-4ac0-92cc-0b5736e70bc0):
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/pykka/actor.py”, line 191, in _actor_loop
self.on_start()
File “/usr/local/lib/python2.7/dist-packages/mopidy_gmusic/actor.py”, line 48, in on_start
self.config[‘gmusic’][‘deviceid’])
File “/usr/local/lib/python2.7/dist-packages/mopidy_gmusic/session.py”, line 21, in login
if not self.api.login(username, password, “test”):
TypeError: login() takes exactly 3 arguments (4 given)

I was getting the same error but found that I had installed the 5.0.0 version of gmusic API instead of the development version.

I got the dev package install and looks like from the logs i’m getting authenticated. However there does not seem to be anything in the music library when a connect a client.

I only see this in log file when I try to browse playlists:
2015-06-19 11:06:49,914 WARNING [3037:Core-7] mopidy.core.playlists: GMusicBackend does not implement playlists.as_list(). Please upgrade it.

This worked for me. Thanks!

Will there be an official fix for this? I tried to install dev branches of the gmusicapi, but I messed up my whole system (I cannot reach the webclient anymore). I guess I have to start from scratch with a new clean image. I would rather wait a few weeks for a new release before digging in too deep right now…

I’ve not looked into this. If a new gmusic release is required then that’s
not under musicbox control. I think that project is looking for a
maintainer.

FWIW, I recently built another raspi/mopidy server, and instead of choosing the “Pi Musicbox” image I decided to build it from scratch as a raspbian/Mopidy/Spotify/GMusic server with the Musicbox frontend. I did this so that I could have the latest Mopidy version at the base of it all.

Anyway, installing the newest stable version of mopidy followed by the newest dev versions of mopidy-gmusic and gmusicapi seemed to work with no needed modification to the code.

The one non-standard modification I did have to make was to go into oauthclient.egg-info and edit the “requires.txt” file to loosen up the version dependency on pyasn1. I did have to wrestle with python development tools and such, but I guess that’s not uncommon with this stuff.

Anyway, it seems there’s hope that this should fix itself if/when musicbox updates to the latest versions of these various packages.

Hope this helps,
Aaron

1 Like