We're using embed SSO to auto-login users from our Next.js app. It works ~95% of the time, but about 1 in 20 attempts fails with a 401 on the token exchange endpoint.
Our flow
- User loads page with embedded Outpost
- Our API route calls
POST /api/community/:slug/embed/sso/tokenwith the user's email - We pass the returned token to the embed via
data-sso-token - Embed exchanges token → sometimes 401
I think it might be a race condition — if the embed script loads and tries to exchange the token before our API has fully returned it, the token might not be valid yet?
Anyone else hitting this?