Skip to content

MyPlexPinLogin workflow broken after PR #1554 (v4.17.2) #1566

Description

@montaguethomas

Describe the Bug

The previously working workflow for MyPlexPinLogin is now broken after commit c4ea6e7 (PR #1554).

It was expected that pin property would return the pin code before calling run() method. This was because the code was generated during initialization of the object:

self._code = None
self._getCode()

I believe common workflows would depend on creation of the object, access to the pin code for user return and display, and executing run thread in another background thread.

Code Snippets

def _get_account_login(myPlexPinLogin: MyPlexPinLogin):
  logger.info(f"Waiting for account login using '{myPlexPinLogin.pin}' code ...")
  myPlexPinLogin.run()
  if not myPlexPinLogin.waitForLogin():
    if myPlexPinLogin.expired:
      logger.warning("Account login timed out.")
    else:
      logger.warning("Account login failed for unknown reason.")
    return
  myPlexAccount = MyPlexAccount(token=myPlexPinLogin.token)
  logger.info(f"Account {myPlexAccount.username} logged in!")
  models.savePlexAccount(myPlexAccount)
  logger.info(f"Account {myPlexAccount.username} saved.")

@app.get("/api/v1/account-login", status_code=status.HTTP_202_ACCEPTED)
async def get_account_login(backgroundTasks: BackgroundTasks):
  myPlexPinLogin = MyPlexPinLogin()
  backgroundTasks.add_task(_get_account_login, myPlexPinLogin)
  return {"message": f"Browse to https://plex.tv/link and enter the code.", "code": myPlexPinLogin.pin, "url": "https://plex.tv/link"}

Expected Behavior

Pin property is populated when accessed.

Additional Context

Related comment from PR: #1554 (comment)

Operating System and Version

All

Plex Media Server Version

All

Python Version

All

PlexAPI Version

4.17.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions