Skip to main content
Most hasp login flows use a browser redirect with a local loopback listener (see OAuth Quickstart). That doesn’t work over SSH, in a container, or on a machine with no browser. The device authorization grant (RFC 8628) is the fallback: the CLI displays a short code, you enter it on any other device with a browser, and the CLI polls for completion. This is a hasp CLI concern, not something most API integrators need to implement directly — it’s documented here because the two endpoints it uses are part of the public /v1 OAuth surface.

Flow overview

  1. The CLI (auto-detecting no browser/loopback available) requests a device code.
  2. It shows you a short user_code and a URL to visit.
  3. You open the URL on any device, sign in, and approve.
  4. Meanwhile the CLI polls the token endpoint until you approve (or the code expires).

1. Request a device code

Stateless, unauthenticated (the device_code itself becomes the proof of possession). Rate-limited (60 requests/minute) since it’s public and DB-writing.
An unknown or inactive client_id returns a 400 with the standard RFC 6749 shape: {"error": "invalid_client", "error_description": "..."}.

2. User approves

Direct the user to verification_uri_complete (or verification_uri + manually entering user_code). This is a normal authenticated, session-based HASP page — the user signs in if needed, sees the code, and approves or denies.

3. Poll the token endpoint

Poll no more often than every interval seconds (the value returned in step 1). While the user hasn’t approved yet, every poll returns:
Once approved, the same poll returns a normal token response:

Polling error codes (RFC 8628 §3.5)

Security notes

  • user_code is short and human-facing by design (RFC 8628’s threat model accepts this given the 15-minute expiry and the fact that guessing it grants nothing without also completing an authenticated approval step).
  • device_code is long, unguessable, and never displayed — only ever transmitted machine-to-machine between the CLI and the token endpoint.
  • A device code is single-use: once exchanged for a token (or denied), polling it again returns invalid_grant.