tehkillerbee / mopidy-tidal

Tidal Backend plugin for Mopidy
Apache License 2.0
93 stars 28 forks source link

mopidy tidal "oauth" JSON file cannot be written due to permissions issue. #41

Closed chicco64 closed 3 years ago

chicco64 commented 3 years ago

HI ! i installed mopidy-tidal on debian10 according to the specs. I specify that I am using the root user for all operations activating "systemctl restart mopidy" in effect appears on "journalctl -u mopidy | tail -5" the invitation link for authentication, and inserting user and psw mopidy would seem to be connected successfully, instead it is not so and the file "tidal- oauth.json "is not created. Can you give me some suggestions? Thank you

tidal_error tidal_error2
tehkillerbee commented 3 years ago

HI @chicco64, I suspect this issue is similar to #40.

The moment, the HOME env. variable is used as a base when generating the path to tidal-oauth.json (See https://github.com/tehkillerbee/mopidy-tidal/blob/83ad5c4363c3c578dc7c67a9ff8ac49bec212443/mopidy_tidal/backend.py#L49)

From your error messages, it looks like this file is never created. But since you have attached logs from two different configurations, it is difficult to tell for sure. On my platform, this path corresponds to the path used in your example, in your first image that is. Can you confirm that the same issue occurs if you run the service as user mopidy?

The mopidy documentation lists the following https://docs.mopidy.com/_/downloads/en/latest/pdf/

core/data_dir
Path to base directory for persistent data files.

Mopidy and extensions will use this path to store data that cannot be be thrown away and reproduced without
some effort. Examples include Mopidy-Local’s index of your media library and Mopidy-M3U’s stored playlists.
When running Mopidy as a regular user, this should usually be $XDG_DATA_DIR/mopidy, i.e. ~/.local/
share/mopidy.
When running Mopidy as a system service, this should usually be /var/lib/mopidy

When running as system service, this path is set as /var/lib/mopidy and I assume it will be $USER when running the mopidy directly. This explains your second picture, where you do not appear to be running mopidy as a service - but as root.

How did you configure your service? I usually follow this guide: https://docs.mopidy.com/en/latest/running/service/

chicco64 commented 3 years ago

thanks for the quick reply !"

I installed mopidy as per technical manual and using systemctl enable mopidy I am attaching again what happens when mopidy restarts after example a reboot and the configuration file, confirm that the access credentials (user and password) must still be entered I believe that systemctl (automatically) uses the user "mopidy" if you need some more logs, no problem....

I have to change the line oauth_file = os.path.join(os.getenv("HOME"), '.config/', 'tidal-oauth.json') ???????

tidal_error3 tidal_error4
chicco64 commented 3 years ago

another logs !

tidal_error5

the "tidal-oauth.json" file is not created when starting mopidy !

this is my /etc/init.d/mopidy

tidal_error6
chicco64 commented 3 years ago

Hi ! i still did numerous tests but i can't get it to work, can you please help me? Thank you !

tehkillerbee commented 3 years ago

@chicco64 I understand you are having trouble getting mopidy-tidal running but it is limited what I can do to help, when I do not experience this issue on the platforms I have tested mopidy-tidal. I might try to test it on a similar platform, if you can describe the steps that you have taken to install it, OS configuration etc.

However, from your logs shown in your latest screenshots, I can see that you do not have permission writing the json file. The python script assumes that these directories are present, so it will not attempt to create them. Instead an error is thrown. It could also be that you do not have permissions writing anything to these folders.

I would start checking whether the /var/lib/mopidy/ directory and its subfolder .config exists - and whether you have permission to edit it. If it does not exist, there must be something wrong with your mopidy configuration.

On my platform, running ls -al /var/lib/mopidy reveals that the user "mopidy" has permissions to write this directory and all the subfolders. So if you are running the service as user mopidy, there should not be any issue.

Also, you are NOT required to change any code to run mopidy-tidal - only the config file. However, in a future version of mopidy-tidal, it might be an idea to pick a more suitable path for the json file, if the default /var/lib/mopidy directory is not found by the script. That would most likely fix the problem that you are experiencing.

An alternative could be to set the json path in the mopidy config file. This would allow the user to pick a more suitable path, if he/she does not have the correct permissions.

chicco64 commented 3 years ago

Hi ! I confirm the problem was in the authorization of the /var/lib/mopidy/.config folder thank you so much !!!