mopidy / mopidy-gmusic

DEPRECATED (Mopidy extension for playing music from Google Play Music)
https://mopidy.com
Apache License 2.0
214 stars 60 forks source link

Not able to authenticate (new install on RPi) #212

Closed p15i closed 4 years ago

p15i commented 5 years ago

I've just installed Mopidy on my Raspeberry Pi (v2 Model B), running Raspbian Stretch Lite (v. Nov 2018).

I installed and configured the Mopidy-GMusic plugin and tried to run Mopidy as a service, but I see the following errors in the log file:

2019-01-03 15:54:45,028 INFO [11520:MainThread] mopidy.__main__: Starting Mopidy 2.2.1
2019-01-03 15:54:45,497 INFO [11520:MainThread] mopidy.config: Loading config from builtin defaults
2019-01-03 15:54:45,516 INFO [11520:MainThread] mopidy.config: Loading config from /etc/mopidy/mopidy.conf
2019-01-03 15:54:45,524 INFO [11520:MainThread] mopidy.config: Loading config from command line options
2019-01-03 15:54:46,533 INFO [11520:MainThread] mopidy.__main__: Enabled extensions: mpd, http, file, stream, m3u, softwaremixer, moped, local, gmusic
2019-01-03 15:54:46,535 INFO [11520:MainThread] mopidy.__main__: Disabled extensions: none
2019-01-03 15:54:46,668 INFO [11520:MainThread] root: Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
2019-01-03 15:54:46,993 INFO [11520:MainThread] root: Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
2019-01-03 15:54:52,393 WARNING [11520:MainThread] py.warnings: /usr/local/lib/python2.7/dist-packages/gmusicapi/__init__.py:4: GmusicapiWarning: gmusicapi.clients.OAUTH_FILEPATH is deprecated and will be removed; use Musicmanager.OAUTH_FILEPATH
  from gmusicapi.clients import Webclient, Musicmanager, Mobileclient

2019-01-03 15:54:52,548 INFO [11520:MainThread] mopidy.commands: Starting Mopidy mixer: SoftwareMixer
2019-01-03 15:54:52,565 INFO [11520:MainThread] mopidy.commands: Starting Mopidy audio
2019-01-03 15:54:52,580 INFO [11520:MainThread] mopidy.commands: Starting Mopidy backends: GMusicBackend, StreamBackend, M3UBackend, FileBackend, LocalBackend
2019-01-03 15:54:52,606 INFO [11520:MainThread] gmusicapi.Mobileclient1: !-- begin debug log --!
2019-01-03 15:54:52,609 INFO [11520:MainThread] gmusicapi.Mobileclient1: version: 11.1.1
2019-01-03 15:54:52,610 INFO [11520:MainThread] gmusicapi.Mobileclient1: logging to: /var/lib/mopidy/.cache/gmusicapi/log/gmusicapi.log
2019-01-03 15:54:52,611 INFO [11520:MainThread] gmusicapi.Mobileclient1: initialized
2019-01-03 15:54:52,617 INFO [11520:MainThread] gmusicapi.Mobileclient1: logged out
2019-01-03 15:54:52,632 WARNING [11520:GMusicBackend-3] py.warnings: <string>:2: GmusicapiWarning: login is deprecated and may break unexpectedly; prefer Mobileclient.oauth_login

2019-01-03 15:54:52,724 INFO [11520:Audio-2] mopidy.audio.actor: Audio output set to "autoaudiosink"
2019-01-03 15:54:52,813 INFO [11520:MainThread] mopidy.local.json: No local library metadata cache found at /var/lib/mopidy/local/library.json.gz. Please run `mopidy local scan` to index your local music library. If you do not have a local music collection, you can disable the local backend to hide this message.
2019-01-03 15:54:52,819 INFO [11520:MainThread] mopidy.local.library: Loaded 0 local tracks using json
2019-01-03 15:54:53,471 INFO [11520:GMusicBackend-3] gmusicapi.Mobileclient1: failed to authenticate
2019-01-03 15:54:53,475 ERROR [11520:GMusicBackend-3] mopidy_gmusic.session: Failed to login to Google Music as "{my-google-login}"
2019-01-03 15:54:53,478 INFO [11520:Thread-8] mopidy_gmusic.backend: Start refreshing Google Music library
2019-01-03 15:54:53,480 INFO [11520:Thread-9] mopidy_gmusic.backend: Start refreshing Google Music playlists
2019-01-03 15:54:53,482 INFO [11520:Thread-8] mopidy_gmusic.backend: Finished refreshing Google Music library in 0s
2019-01-03 15:54:53,491 INFO [11520:Thread-9] mopidy_gmusic.playlists: Loaded 0 playlists from Google Music
2019-01-03 15:54:53,501 INFO [11520:MainThread] mopidy.commands: Starting Mopidy core
2019-01-03 15:54:53,505 INFO [11520:Thread-9] mopidy_gmusic.backend: Finished refreshing Google Music playlists in 1s
2019-01-03 15:54:53,632 INFO [11520:MainThread] mopidy.commands: Starting Mopidy frontends: GMusicScrobblerFrontend, MpdFrontend, HttpFrontend
2019-01-03 15:54:53,652 INFO [11520:MainThread] mopidy.mpd.actor: MPD server running at [::ffff:127.0.0.1]:6600
2019-01-03 15:54:53,686 INFO [11520:HttpFrontend-14] mopidy.http.actor: HTTP server running at [::ffff:0.0.0.0]:6680
2019-01-03 15:54:53,688 INFO [11520:MainThread] mopidy.commands: Starting GLib mainloop

The line with the error is:

2019-01-03 15:54:53,475 ERROR [11520:GMusicBackend-3] mopidy_gmusic.session: Failed to login to Google Music as "{my-google-login}"

My config file is:

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[local]
media_dir = /var/lib/mopidy/media

[m3u]
playlists_dir = /var/lib/mopidy/playlists

[http]
enabled = true
hostname = 0.0.0.0

[gmusic]
username = {my-google-login}
password = {my-google-password}
all_access = true
deviceid = {my-device-id}

Mopidy was installed via apt-get after adding the repository, and the Mopidy-GMusic plugin was installed using pip.

I received an email that there was a new sign-in to my account from a new Android device, so clearly the authentication is at least partially working.

I've also enabled less secure logins for my google account to see if that was the problem, but it's not making a difference. There's no 2FA enabled for this account either.

Any ideas as to what could be happening? Is there any other info or file that I can provide which would help?

sschuberth commented 5 years ago

My guess is that the version 10.1 of gmusicapi that mopidy-gmusic uses is simply too outdated. There have been several authentication-related updates in gmusicapi since then.

belak commented 5 years ago

Oof, I didn't realize they had deprecated password login. That's a bigger change than I'd like, but I'll see what I can do... I'm going to have quite a few unhappy people here when that finally gets pushed.

belak commented 5 years ago

I've updated this to use the oauth flow and a newer version of gmusicapi. Can you try with the current master branch and let me know if it works for you?

sschuberth commented 5 years ago

Thanks @belak! Even if I'm not the OP I'm willing to give it a try. As I'm not a Python person, could you maybe add instructions to the README's "Installation" section on how to install this package form source instead of from PyPI?

kingosticks commented 5 years ago

Hi @belak, have you considered implementing the initial auth process using Mopidy's Command API (https://docs.mopidy.com/en/latest/extensiondev/#example-command)?

belak commented 5 years ago

@kingosticks I honestly didn't know that was a thing. I'll have to take a look when I have more time.

digitalneoplasm commented 5 years ago

The fix is working well here! At first I missed the need to add the 2nd key to my config file, but I figured it out when it kept failing to start (maybe that could be highlighted somehow?).

jacobobryant commented 5 years ago

The fix works for me too. I've also added a PR which uses Mopidy's command API for the initial auth process: #221

jjok commented 4 years ago

I think this can be closed now that #221 has been merged.