<@U07FRRZH2GN> getting 401 unauthorized while gene...
# server-api
f
@icy-policeman-64898 getting 401 unauthorized while generating token. It was working just fine earlier
r
This is nearly always LiveKit credentials not set correctly or the system clock is not correct.
b
@refined-appointment-81829 Highjacking this thread, but related to mine above it: I tried debugging both these at the time. I verified the claims map on the issued token contained a valid expiration. It was done correctly, and showed the token was valid for 1h. (You can check this yourself comparing the Slack timestamp when I posed to the claim.) Additionally, I rotated and verified the LK credentials used were correct. Expires At: Tuesday, September 2, 2025 85957 AM GMT-07:00 DST Despite both those, I encountered the 401 issue on multiple projects. Then suddenly both started working again. Now seeing another user has this issue at the same time, I really encourage someone to check logs and see if there's an outlier on LK's side. Any information to prevent this happening again is valuable to me and would be much appreciated! 🙏
r
did you check
nbf
?
Most of the time when I have seen this the system clock is a little fast and try and use the token before it becomes valid.
b
No, looks good there too, I'll convert that real quick just to make it convenient to debug. NBF: Tuesday, September 2, 2025 75957 AM GMT-07:00 DST
Token was generated about 8:03 maybe 8:04am my time.
r
ok, need to know down to the milli second to check its validity
b
I have logs and can get that info for you, one moment.
r
Why was the nbf generated for past?
seems fishy
does it fail 100% or intermittent?
b
2025-09-02 075951.760 PT was the exact request timestamp in GCP
r
that looks like the issue
Glad you found the issue.
b
Just so I understand correctly, the solution would be to set the NBF claim with a margin large enough to not cause issues with other systems? Given a clock desync of a couple seconds may be possible?
(I obviously don't control the internal clocks at Cloud Run lol)
r
no, the correct solution is to keep systems clock in sync with ntp
b
Alright, well that safely puts this outside the scope of LK then. I appreciate the direction @refined-appointment-81829 and should be able to figure out something to keep this from happening. I appreciate the quick turnaround!
👍🏼 1
@refined-appointment-81829 Off the phone here with my GCP account rep. They have had desynchronized clocks reported to their Cloud Run offering by multiple customers today. Cloud Run VMs are supposed to be automatically synchronized with Google's Public NTP. Looks like that's temporarily degraded for some customers today. If you see this issue reported again by other LK customers today, check if they are on GCP.
r
Thank you for letting me know.
🙌 1