-
Notifications
You must be signed in to change notification settings - Fork 200
Closed
Description
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:
python-plexapi/plexapi/myplex.py
Lines 1719 to 1720 in 30f9122
| 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
Metadata
Metadata
Assignees
Labels
No labels