hyperlink / plex-tv-cleanup

Automatically delete watched TV shows on Plex
MIT License
5 stars 0 forks source link

Error: Authentication failed #26

Closed scottrobertson closed 2 years ago

scottrobertson commented 3 years ago

Hey

I have this running perfectly on the local machine, but i want to be able to run it from my Raspberry Pi instead. But when i try, i am getting the following:

Error: Authentication failed, reason: Invalid status code in authentication response from Plex.tv, expected 201 but got 401
    at /usr/lib/node_modules/plex-tv-cleanup/node_modules/plex-api/lib/api.js:221:36
    at tryCatcher (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/util.js:16:23)
    at Promise.errorAdapter [as _rejectionHandler0] (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/nodeify.js:35:34)
    at Promise._settlePromise (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/promise.js:601:21)
    at Promise._settlePromise0 (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/plex-tv-cleanup/node_modules/bluebird/js/release/async.js:15:14)

The username/password/host are all correct, and they work on the localhost machine.

Any ideas?

scottrobertson commented 3 years ago

Oh, this is not even working locally actually.

hyperlink commented 3 years ago

Looks like Plex doesn't like the username and password provided. Double-check the values in .plex-tv-cleanup-config.json

You can also create your own request in Postman to troubleshoot. Send a POST to https://plex.tv/users/sign_in.json with your password and username in Basic Auth. There are some headers that are required such as X-Plex-Product, X-Plex-Version, and X-Plex-Client-Identifier Good luck!

scottrobertson commented 3 years ago

I have an idea. I think it may be due to 2FA. You can just append it to the end of the password. Will try that out soon :)

scottrobertson commented 3 years ago

Yup, that was it. Appending the 2fa code works. Obviously that won't work when the code expires, so I am not 100% sure the best way to handle this.