reachthingsDocs
EN
Dashboard
AuthenticationOverview
Authentication

How auth works

Three separate layers. Your agent never sees a manufacturer token, and a manufacturer never sees your agent.

On this page
Your agentMCP client
ReachthingsMCP server + grants
Manufacturer cloudSmartThings, …
① Agent OAuth · bearer token
② Manufacturer OAuth · encrypted, server-side
③ Grant: agent × device × action → checked on every call

① Agent OAuth

Reachthings is an OAuth 2.1 protected resource that follows the MCP authorization spec. Standard MCP SDKs handle this flow automatically.

  1. Agent calls /mcp without a token → 401 with WWW-Authenticate: Bearer resource_metadata="…"
  2. Agent reads /.well-known/oauth-protected-resource and discovers the authorization server.
  3. User signs in and consents (Authorization Code + PKCE, resource parameter set to the MCP URL).
  4. Agent retries with Authorization: Bearer <token>.
ScopeAllows
devices:readlist_devices, get_device, get_device_state, get_command_status, list_schedules, get_schedule, list_schedule_runs
devices:controlexecute_device_action, cancel_command, create_schedule, update_schedule, cancel_schedule, pause_schedule, resume_schedule
Scopes
devices:read
Allowslist_devices, get_device, get_device_state, get_command_status, list_schedules, get_schedule, list_schedule_runs
devices:control
Allowsexecute_device_action, cancel_command, create_schedule, update_schedule, cancel_schedule, pause_schedule, resume_schedule
Token claimMeaning
subThe end user. Decides whose devices are visible.
azpYour OAuth client. Decides which grant applies.
audMust equal the MCP URL. Tokens for other audiences are rejected.
Token claims
sub
MeaningThe end user. Decides whose devices are visible.
azp
MeaningYour OAuth client. Decides which grant applies.
aud
MeaningMust equal the MCP URL. Tokens for other audiences are rejected.

When multiple processes share one connection

A Hermes gateway and a G2 adapter may use the same token store for a Reachthings connection. With refresh token rotation, a second process can submit a stale refresh token after the first process has refreshed successfully. A lock held only in process memory cannot prevent this race.

  • Allow only one refresh at a time per connection. For processes sharing a file on one host, use an inter-process file lock.
  • After acquiring the lock, read the token store again. If another process has already saved a valid access token, use it. Call the token endpoint only if a refresh is still needed.
  • After a successful refresh, save the new access token, its expiry, and any replacement refresh token together before releasing the lock.
  • If the lock times out, read the store again. If no valid access token is available, return a retryable error. The next attempt must acquire the same lock before refreshing.
  • If the client reports login_required, check whether a refresh token was stored and inspect the HTTP status and OAuth error code from the last refresh attempt. Prompt the user to sign in again only when the existing grant cannot be recovered with the latest stored credentials. Never log token values.

② Manufacturer accounts

Users link brands in the dashboard with the manufacturer's own sign-in. Tokens are encrypted and refreshed before they expire. If a manufacturer revokes access, the connection shows reauth_required and pending commands are held, not dropped.

Planned · Connect link. Generate a hosted link and send your users there from your own app, so they never visit the Reachthings dashboard. Join the waitlist

③ Agent grants

The first time a new client signs in for a user, Reachthings creates an empty grant. The user picks devices and actions, and can require approval per action. Revoking a grant returns 403 to that agent and rejects its pending commands with permission_revoked. Other agents are unaffected.

// Agent without access to a device
{ "command_id": null,
  "error": { "code": "DEVICE_NOT_ACCESSIBLE",
             "message": "The requested device was not found or is not accessible from this connection." } }