Kayomani / PlexExternalPlayer

Allows you to use Plex to browse your media then play the files in your favorite media player (where the files are local).
GNU General Public License v3.0
115 stars 14 forks source link

Could not find authentication info #32

Open Flyinlion opened 5 years ago

Flyinlion commented 5 years ago

× Plex External Player Error getting metadata from http://127.0.0.1:32400/library/metadata/235513?includeConcerts=1&includeExtras=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeChapters=1&asyncCheckFiles=0&asyncRefreshAnalysis=0&asyncRefreshLocalMediaAgent=0Error: undefined

× Plex External Player Could not find authentication info

chast64 commented 5 years ago

Having the same issue (Firefox only). Doesn't appear on chrome though.

kaiontour commented 5 years ago

any news on this? I still cannot use an my own domain from outsite...

kaiontour commented 5 years ago

my fault, did not install agent...

Flyinlion commented 5 years ago

I wish I had the link for you, but there is a string that sets domain to 255.255.255.0 or something like that... Mine is working again after a re install and running that string command...

On Thu, May 2, 2019, 2:22 AM kaiontour notifications@github.com wrote:

any news on this? I still cannot use an my own domain from outsite...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Kayomani/PlexExternalPlayer/issues/32#issuecomment-488564466, or mute the thread https://github.com/notifications/unsubscribe-auth/AK7VCMB2W53W3JVNXDIU6QLPTKCEBANCNFSM4GL76DIQ .

enchained commented 3 years ago

I had a similar auth error on v1.19, but not on v1.16, so I compared in debug and the difference was in it hardcoding 'https' now, while my server isn't SSL. You can try to replace https with http in this line and see if it works then:

pmsUrls.set(parts[i].getAttribute('clientIdentifier'), 'https://' + connections[j].getAttribute('address') + ':' + connections[j].getAttribute('port'));

It still didn't work on my second Plex server, the difference being the first was a Synology package, the second is in docker. My guess is that IP like 127.0.0.1 in the error comes from inside the docker, and maybe Plex mistakenly reports it instead of the host IP (cause it doesn't know it). If you have a single Plex server and it's in docker, you can try to hardcode its address (IP or domain) instead of relying on data inside the connections array. My working code looks like that now:

pmsUrls.set(parts[i].getAttribute('clientIdentifier'), 'http://myserverdomain.com' + ':' + connections[j].getAttribute('port'));

For multiple servers you probably could map server names or other ids from the connections array and manually assign them real addresses.

Also I want to mention that v1.19 fixed some previous issues, it's been working fine as of now after my edits, both on my server domain and even on app.plex.tv now. But as of late I discovered another alternative, https://github.com/iwalton3/plex-mpv-shim. It restricts you to using the mpv player as external, which may take time to get used to, and harder to configure inputs without the GUI, but it shows up on Tautulli history logs and will remember your pause position in Plex, cause it basically acts like a native Plex player cast destination and can be controlled from mobile Plex app etc. I already used mpv before, so it feels like a much nicer/lighter/headless alternative to any desktop Plex player, especially when paired with a mobile device (but cast works from the web Plex too, may need a userscript to run though).

Flyinlion commented 3 years ago

I appreciate your help. My post was quite a while ago. Now, I just have problems with accessing outside my home network... I did figure out it will work when I activate manual connections within my mobile app, and use my IP given to be my VPN (adding the port of course).

Your info about (essentially,github shim) was useful, but I haven't tried it yet.

On Mon, Jan 18, 2021, 12:49 PM Anna Gerasimova notifications@github.com wrote:

I had a similar auth error on v1.19, but not on v1.16, so I compared in debug and the difference was in it hardcoding 'https' now, while my server isn't SSL. You can try to replace https with http in this line and see if it works then:

pmsUrls.set(parts[i].getAttribute('clientIdentifier'), 'https://' + connections[j].getAttribute('address') + ':' + connections[j].getAttribute('port'));

It still didn't work on my second Plex server, the difference being the first was a Synology package, the second is in docker. My guess is that IP like 127.0.0.1 in the error comes from inside the docker, and maybe Plex mistakenly reports it instead of the host IP (cause it doesn't know it). If you have a single Plex server and it's in docker, you can try to hardcode its address (IP or domain) instead of relying on data inside the connections array. My working code looks like that now:

pmsUrls.set(parts[i].getAttribute('clientIdentifier'), ' http://myserverdomain.com' + ':' + connections[j].getAttribute('port'));

For multiple servers you probably could map server names or other ids from the connections array and manually assign them real addresses.

Also I want to mention that v1.19 fixed some previous issues, it's been working fine as of now after my edits, both on my server domain and even on app.plex.tv now. But as of late I discovered another alternative, https://github.com/iwalton3/plex-mpv-shim. It restricts you to using the mpv player as external, which may take time to get used to, and harder to configure inputs without the GUI, but it shows up on Tautulli history logs and will remember your pause position in Plex, cause it basically acts like a native Plex player cast destination and can be controlled from mobile Plex app etc. I already used mpv before, so it feels like a much nicer/lighter/headless alternative to any desktop Plex player, especially when paired with a mobile device (but cast works from the web Plex too, may need a userscript to run though).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Kayomani/PlexExternalPlayer/issues/32#issuecomment-762393174, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7VCMFVQ44KD7ZSDLL5XKDS2RYCDANCNFSM4GL76DIQ .

1LucKyLuke commented 3 years ago

I had a similar auth error on v1.19, but not on v1.16, so I compared in debug and the difference was in it hardcoding 'https' now, while my server isn't SSL. You can try to replace https with http in this line and see if it works then:

pmsUrls.set(parts[i].getAttribute('clientIdentifier'), 'https://' + connections[j].getAttribute('address') + ':' + connections[j].getAttribute('port'));

Thanks for pointing out the https issue. Did not notice when I made the changes for 1.19 since I had security exceptions setup for my servers. Changed it back to http, see pull request #47 I also fixed an issue in this PR which caused auth errors directly after login because the token was not accessible right away.

Regarding docker, you could try running your docker with ADVERTISE_IP variable set. -e ADVERTISE_IP="http://:32400/" With that Plex should return the set address instead of it's docker IP

enchained commented 3 years ago

@1LucKyLuke Thank you for the fixes!

Regarding docker, you could try running your docker with ADVERTISE_IP variable set. -e ADVERTISE_IP="http://:32400/" With that Plex should return the set address instead of it's docker IP

Thanks, I didn't know about that. Will it work with the linuxserver.io image, or just the official one? Currently I'm running the linuxserver one and their docs do not have that info. Also plexinc/pms-docker docs suggest this option for the bridged networking, while I usually use host network for Plex.

1LucKyLuke commented 3 years ago

Did not try it myself since I'm also running the linuxserver.io image and not the official one. It's just what I found when looking for the issue you described. What I find interesting is, is that I'm also running my docker in host network mode and I'm experiencing no issues.

You could try calling the Plex Api to see what IPs are reported from the server: https://plex.tv/api/resources?includeHttps=1&X-Plex-Token=yourPlexToken

It will give you a list of all your known devices as well as their IPs. This is also what's being used by the script to find out all your servers. Just make sure you don't post the response here, since it contains your public IPs as well as your auth token.

If you don't know how to obtain your token you can look here: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/

enchained commented 3 years ago

You could try calling the Plex Api to see what IPs are reported from the server: https://plex.tv/api/resources?includeHttps=1&X-Plex-Token=yourPlexToken It will give you a list of all your known devices as well as their IPs. This is also what's being used by the script to find out all your servers.

Thanks! For the linuxserver.io Plex server (remotely hosted on Hetzner) I got just 1 <Device> with 4 <Connection> items there, the first 3 of them have the attribute local="1" and subsequent IPs in the range 172.16.X.X – 172.31.X.X, and the script error I got was with one of them. The 4th connection is the actual external IP that I would prefer to be used, it has an attribute local="0". I did ifconfig and it looks like those 3 were just the host LAN IPs, so in my case it isn't a docker issue.

For the comparison, a local docker-less server on Synology NAS shows only 2 connections, one of them is Synology LAN IP with local="1", the other is my home network external IP with local="0". I was testing the script from home, and it requested the LAN IP when I noticed the https issue, it started working just by changing the protocol.

If I follow the script, only the (first) local="1" address is being used. Is there any particular reason for that? Probably that is what makes the remote server inaccessible without hardcoding? But setting it to local="0" wouldn't work for everyone either, cause if the LAN server doesn't have the Plex port forwarded to the outside, it won't be accessible outside the LAN network. But in that case there's probably no other way than recommend to forward the Plex port.

My guess is those who are on LAN, would prefer the local connection anyway. Maybe the script could work more universally if we take the first local address, immediately test if it's accessible by making a request, and if not, replace it with the first not-local in the catch?

1LucKyLuke commented 3 years ago

The local="1" is actually because I didn't even consider that one would use it with a remote server, assuming the most common use-case would be having the server in your LAN.

Can you try changing the ìf where it checks if its a local connection from: if (connections[j].getAttribute('local') == '1') { to: if (connections[j].getAttribute('local') == parts[i].getAttribute('publicAddressMatches')) {

I looked at the Plex API response and it's comparing the publicAddress of the servers against the one from which the request is made. So with that change the script will use the first local='1' address for servers where the public address matches and the first local='0' if it does not.

I can't test it on my end so please let me know if that works for you.