EthanC / Perplex

Discord Rich Presence implementation for Plex.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] 401 Unauthorised Handle & Fixing

Alipoodle opened this issue · comments

Issue

I'm a user on a Friend's server and I'm able to authenticate with my account however I'm getting a 401 unauthorised when getting the current sessions.
My Logs are below to try and help.

Username & Passwords are correct as I can authenticate my account, Server name is correct as I checked via the debug, and it would have crashed earlier.

Any Help/Advice you could provide me?

Traceback:

Traceback (most recent call last):
  File "$PYTHON_PATH\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "$PYTHON_PATH\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "$USER_PATH\.vscode\extensions\ms-python.python-2022.0.1814523869\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "$USER_PATH\.vscode\extensions\ms-python.python-2022.0.1814523869\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
    run()
  File "$USER_PATH\.vscode\extensions\ms-python.python-2022.0.1814523869\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "$PYTHON_PATH\lib\runpy.py", line 269, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "$PYTHON_PATH\lib\runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "$PYTHON_PATH\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "g:\Documents\Github\Perplex\perplex.py", line 418, in <module>
    Perplex.Initialize(Perplex)
  File "g:\Documents\Github\Perplex\perplex.py", line 38, in Initialize
    session: Optional[Union[Movie, Episode, Track]] = Perplex.FetchSession(
  File "g:\Documents\Github\Perplex\perplex.py", line 206, in FetchSession
    sessions: List[Media] = server.sessions()
  File "$USER_PATH\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\server.py", line 726, in sessions
    return self.fetchItems('/status/sessions')
  File "$USER_PATH\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 260, in fetchItems
    data = self._server.query(ekey, params=url_kw)
  File "$USER_PATH\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\server.py", line 678, in query
    raise Unauthorized(message)
plexapi.exceptions.Unauthorized: (401) unauthorized; https://<Plex-IP-Address>.<Plex-UUID>.plex.direct:32400/status/sessions <html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>

Console Log:

2022-02-25 22:12:49.898 | INFO     | __main__:Initialize:29 - Perplex
2022-02-25 22:12:49.901 | INFO     | __main__:Initialize:30 - https://github.com/EthanC/Perplex
2022-02-25 22:12:49.908 | SUCCESS  | __main__:LoadConfig:80 - Loaded configuration
2022-02-25 22:12:50.195 | SUCCESS  | __main__:LoginPlex:139 - Authenticated with Plex
2022-02-25 22:12:50.446 | SUCCESS  | __main__:LoginDiscord:165 - Authenticated with Discord
commented

Without further information on this specific error or being able to reproduce it myself, there's not much I can do to fix it. This seems to be a problem with the permissions of the configured user and Plex Media Server, not the script itself.