Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PlexTraktSync is broken for Plex 2FA users

ericswpark opened this issue · comments

Confirmation

  • I have read the README.md on the project homepage
  • I have checked if identical issue already exists
  • I have tried downgrading to find version that can be used as a workaround

The problem

Trying to run PTS for the first time and I'm getting a 401 unauthorized error when signing in.

Error trace / logs

> plextraktsync sync
INFO     PlexTraktSync [0.27.4]
Please enter your Plex username or e-mail (ericswpark): ericswpark
If you have 2 Factor Authentication enabled on Plex you can append the code
to your password below (eg. passwordCODE)
Please enter your Plex password:
Log in to Plex failed: '(401) unauthorized;
https://plex.tv/api/v2/users/signin <?xml version="1.0" encoding="UTF-8"?>
<errors>   <error code="1029" message="Please enter the verification code"
status="401"/> </errors> ', Try again.

Expected behavior

Logging in to Plex works

Steps to reproduce the behavior

  1. Run plextraktsync sync
  2. Type in username
  3. Type in password with TOTP code

Inspect of problematic items

No response

Workarounds

No response

Install method

pipx

Config file contents

# Config File: /Users/ericswpark/Library/Application Support/PlexTraktSync/config.yml
cache:
  path: /Users/ericswpark/Library/Caches/PlexTraktSync/trakt_cache
excluded-libraries:
- Private
- Family Holidays
config:
  dotenv_override: true
plex:
  timeout: 30
logging:
  append: true
  console_time: false
  debug: false
  filename: plextraktsync.log
  filter_loggers: null
  filter: null
sync:
  plex_to_trakt:
    collection: true
    clear_collected: false
    ratings: true
    watched_status: true
    watchlist: true
  trakt_to_plex:
    liked_lists: true
    ratings: true
    watched_status: true
    watchlist: true
    watchlist_as_playlist: false
  rating_priority: plex
watch:
  add_collection: false
  remove_collection: false
  scrobble_threshold: 80
  username_filter: true
  media_progressbar: true
xbmc-providers:
  movies: imdb
  shows: tvdb

Version

PlexTraktSync 0.27.4

Python Version

3.11.5

Operating System and Version

macOS 13.5.2

Discussed here :

@twolaw the linked discussion goes nowhere and the API endpoint has changed to v2. Considering that my Plex clients authenticate to Plex's servers fine, I feel like this is on PTS's side.

def myplex_login(username, password):
while True:
username = Prompt.ask(PROMPT_PLEX_USERNAME, default=username)
print(NOTICE_2FA_PASSWORD, highlight=False)
password = Prompt.ask(PROMPT_PLEX_PASSWORD, password=True, default=password, show_default=False)
try:
return MyPlexAccount(username, password)

We attempt to log in here with the password and 2FA code concatenated. However, the plexapi library that PTS depends on expects a separated code argument:

https://github.com/pkkid/python-plexapi/blob/7da49eb711663f8b4e2cebcac41298c6324c1427/plexapi/myplex.py#L117

In this commit, the API changed from concatenating the two to sending the 2FA code separately:

pkkid/python-plexapi@013d1a2#diff-a4d2871af21be6195cd340e0e5be3815c6ffba03bf855655b9a8dfedfd095984L107-R134

This commit was added July 27, and shipped with 4.15.0 of the library, which PTS updated to with the automated Dependabot PR:

#1542

So PTS has been broken for users using 2FA ever since tag 0.27.1, which was released 2 weeks ago.