Skip to content

Commit 705be71

Browse files
Resolve issue accessing pin code before running thread. (#1567)
* Resolve issue accessing pin code before running thread. Fixes #1566. * Update to use _getCode() instead of _code * Correct pin login example.
1 parent 0a0cbb7 commit 705be71

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plexapi/myplex.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ class MyPlexPinLogin:
17221722
17231723
from plexapi.myplex import MyPlexAccount, MyPlexPinLogin
17241724
1725-
pinlogin = MyPlexPinLogin()
1725+
pinlogin = MyPlexPinLogin(oauth=True)
17261726
pinlogin.run()
17271727
print(f'Login to Plex at the following url:\\n{pinlogin.oauthUrl()}')
17281728
pinlogin.waitForLogin()
@@ -1759,7 +1759,7 @@ def pin(self):
17591759
"""
17601760
if self._oauth:
17611761
raise BadRequest('Cannot use PIN for Plex OAuth login')
1762-
return self._code
1762+
return self._getCode()
17631763

17641764
def oauthUrl(self, forwardUrl=None):
17651765
""" Return the Plex OAuth url for login.
@@ -1779,7 +1779,7 @@ def oauthUrl(self, forwardUrl=None):
17791779
'context[device][platformVersion]': headers['X-Plex-Platform-Version'],
17801780
'context[device][device]': headers['X-Plex-Device'],
17811781
'context[device][deviceName]': headers['X-Plex-Device-Name'],
1782-
'code': self._code
1782+
'code': self._getCode()
17831783
}
17841784
if forwardUrl:
17851785
params['forwardUrl'] = forwardUrl
@@ -1848,6 +1848,9 @@ def checkLogin(self):
18481848
return False
18491849

18501850
def _getCode(self):
1851+
if self._code:
1852+
return self._code
1853+
18511854
url = self.PINS
18521855

18531856
if self._oauth:

0 commit comments

Comments
 (0)