watchstate: [BUG] ERROR 429 with Plex user tokens

Describe the bug

Hi! I’m in the process of moving between plex servers and of course wish to synchronise watch states.

When my admin token goes to retrieve the user-id’s and their associated Token’s I’m getting 429’s for some users.

To Reproduce

$ docker exec -ti watchstate-user1 console config:add legacyplex
...
Trying to get users list from backend. Please wait...
[2023-08-02T10:43:20+01:00] ERROR: Request for [legacyplex] user [user1] temporary access token responded with unexpected [429] status code.
[2023-08-02T10:43:20+01:00] ERROR: Request for [legacyplex] user [user3] temporary access token responded with unexpected [429] status code.
[2023-08-02T10:43:20+01:00] ERROR: Request for [legacyplex] user [user6] temporary access token responded with unexpected [429] status code.
[2023-08-02T10:43:20+01:00] ERROR: Request for [legacyplex] user [user9] temporary access token responded with unexpected [429] status code.
[2023-08-02T10:43:20+01:00] ERROR: Request for [legacyplex] user [user11] temporary access token responded with unexpected [429] status code.
Select [legacyplex] User. 
------------------
Unlike other media backends, Plex does not use user id to scope API calls, they use
Tokens to do so, thus the user is mainly used for webhook events.
> 
  [0 ] user1
  [1 ] user2
  [2 ] user3
  [3 ] user4
...

So whilst no user token was retrieved the user is still listed as a valid option, when choosing such a user (with the ERROR 429 line above) it takes the Admin user’s token and sync’s that instead.

Expected behavior

  • No 429 errors? 😃
  • If a token could not be retrieved fail rather than use the Admin token for Plex setups

That aside - I have used ‘console backend:users:list --with-tokens’ and get the same behaviour where there are some user’s who’s tokens I never see populated - so I’m not sure a retry-until-200 will work either.

I did not see anything useful on the Plex server logs at that time either.

Basic report

$ docker exec -ti watchstate-user1 console system:report
[ Basic Report ]

WatchState Version: 6472497
PHP Version: 8.2.7
Timezone: Europe/London
Running in Container? Yes
Data Path: /config
Temp Path: /config
Database Migrated?: Yes
Has .env file? No
Is Tasks Runner working? Yes
Report Generated At: 2023-08-02T10:30:12+00:00

[ Backends ]

[ Tasks ]

[ Import ]

Is Task enabled? Yes
Which flags are used to run the task? -v
When the task scheduled to run at? 0 */1 * * *
When is the next scheduled run? 2023-08-02T11:00:00+00:00

[ Export ]

Is Task enabled? Yes
Which flags are used to run the task? -v
When the task scheduled to run at? 30 */1 * * *
When is the next scheduled run? 2023-08-02T11:30:00+00:00

[ Push ]

Is Task enabled? No

[ Backup ]

Is Task enabled? No

[ Prune ]

Is Task enabled? Yes
Which flags are used to run the task? -v
When the task scheduled to run at? 0 */12 * * *
When is the next scheduled run? 2023-08-02T11:00:00+00:00

[ Indexes ]

Is Task enabled? Yes
Which flags are used to run the task? -v
When the task scheduled to run at? 0 3 * * 3
When is the next scheduled run? 2023-08-09T02:00:00+00:00

[ Requests ]

Is Task enabled? Yes
Which flags are used to run the task? -v --no-stats
When the task scheduled to run at? */2 * * * *
When is the next scheduled run? 2023-08-02T10:32:00+00:00

[ Logs ]

[ /config/logs/app.20230802.log ]

[2023-08-02T10:07:27.936274+01:00] logger.ERROR: Request for [legacyplex] user [user1] temporary access token responded with unexpected [429] status code. {"user_id":"02bda07905e42cb5"} []
[2023-08-02T10:07:27.972071+01:00] logger.ERROR: Request for [legacyplex] user [user3] temporary access token responded with unexpected [429] status code. {"user_id":"5d51c84845f4e0df"} []
[2023-08-02T10:43:20.243282+01:00] logger.ERROR: Request for [legacyplex] user [user6] temporary access token responded with unexpected [429] status code. {"user_id":"37318fa16a24c9b2"} []
[2023-08-02T10:43:20.278233+01:00] logger.ERROR: Request for [legacyplex] user [user9] temporary access token responded with unexpected [429] status code. {"user_id":"4e0cc17cd2dda32a"} []
[2023-08-02T10:43:20.312063+01:00] logger.ERROR: Request for [legacyplex] user [user11] temporary access token responded with unexpected [429] status code. {"user_id":"b0861764d517b282"} []

[ /config/logs/access.20230802.log ]

access log file is empty or does not exists.

[ /config/logs/task.20230802.log ]

No backends were found.
--------------------------
Task: import (Started: Wed, 11:00:21 BST)
Command: /opt/app/bin/console state:import -v
Exit Code: 1 (Ended: Wed, 11:00:21 BST)
--------------------------
[2023-08-02T11:00:21+01:00] WARNING: No backends were found

[ /config/logs/app.20230801.log ]

app log file is empty or does not exists.

[ /config/logs/access.20230801.log ]

access log file is empty or does not exists.

[ /config/logs/task.20230801.log ]

task log file is empty or does not exists.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for that!

And you were right - once access was provided of course it worked - thanks for the fix!

Glad it’s working for you, i will go ahead and merge dev into master in a bit

Are you suggesting I setup as a admin user then edit the configuration file with the token of the user I’m after?

correct use the admin token first to generate the config after that replace the token as needed for each user until i rework the plex auth flow.