Home / Companies / WorkOS / Blog / Post Details
Content Deep Dive

How to verify WorkOS access tokens in your own API

Blog post from WorkOS

Post Details
Company
Date Published
Author
Maria Paktiti
Word Count
2,452
Company Posts That Month
89
Language
English
Hacker News Points
-
Post removed?
No
Summary

WorkOS bearer-token authentication for mobile and other API clients requires server-side middleware that extracts an access token, verifies it against the environment’s cached JWKS using jose, validates its signature, expiry, issuer, and a deliberately configured audience, and attaches verified identity claims to the request. Clients should send access tokens only, never refresh tokens, while APIs should use the stable sub claim to identify users, scope multi-tenant data by org_id, authorize through permissions rather than mutable role names, and account for impersonation through the act claim. Verification failures should distinguish invalid or expired tokens, which return 401 responses, from temporary JWKS retrieval failures, which should return 503 with retry guidance rather than signing users out; expired-token responses should enable clients to refresh and retry transparently. Refresh operations need serialization because rotating refresh tokens can create race conditions, and transient refresh failures should not be treated as terminal. The guidance also emphasizes avoiding token logging, using session IDs for server-side revocation, configuring custom claims carefully, and considering WorkOS API Gateway as an alternative authentication layer.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
MCP 1 8,107 809 199 -26%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.