Device authorization
Use the OAuth 2.0 device authorization flow for CLIs, TVs, and other devices
that cannot conveniently receive a browser callback. The application starts
the flow, the user approves it in a browser, then the application picks up the
token package from /token.
The device flow does not give the application the user's password.
ML-DSA device token issuance and refresh have passed the native signing and
verification campaign. Updated M7 token SDK source can verify those signatures
with the optional m7crypto extension, a compatible backend/key resolver and
an explicit algorithm allowlist. This does not update existing immutable SDK
ZIPs. Device token pickup returns JSON to the client rather than placing its
tokens in the relying site's browser cookies; resource headers, proxies and
storage must still accommodate their size. See post-quantum storage limits
before reusing such tokens in the current Web SDK.
Client requirements
The OAuth client must:
- be active;
- be enabled for the device-code grant;
- use its configured token endpoint authentication method; and
- not be an M7 admin application.
A confidential client may use client_secret_basic, client_secret_post, or
another configured confidential method. A public CLI may use
token_endpoint_auth_method=none and send only client_id. Never embed a
confidential client secret in a device app or browser.
Start device authorization
POST https://sso.user.m7.org/device_authorization
Content-Type: application/x-www-form-urlencoded
Authenticate the client in the same way it authenticates to /token.
For client_secret_jwt or private_key_jwt, the client assertion audience is
either the canonical authorization-server issuer https://sso.user.m7.org or
the exact device-authorization endpoint URL.
An mTLS-authenticated client instead presents its registered certificate and
uses https://mtls-sso.user.m7.org/device_authorization, as published in
discovery. The browser verification URL and canonical issuer do not change.
| Field | Required | Description |
|---|---|---|
client_id |
Yes for none and usually present otherwise |
OAuth client identifier. |
scope |
No | Requested space-delimited scopes. Omission requests the client's configured allowed scopes except orgs, which must be requested explicitly. |
aud |
No | Exact registered resource audience. Repeat it to request several audiences. Omission requests the client's complete configured audience set. |
nonce |
No | Carries into an ID token when openid is granted. |
fingerprint |
No | 64-character hexadecimal M7 credential binding. |
access_expires |
No | Requested access-token lifetime in seconds. |
refresh_expires |
No | Requested refresh-token lifetime in seconds. |
claims |
No | JSON object for claims requested for both token classes. |
access_claims |
No | JSON object for requested access-token claims. |
refresh_claims |
No | JSON object for requested refresh-token claims. |
Example for a confidential client:
curl --fail-with-body --silent --show-error \
--request POST 'https://sso.user.m7.org/device_authorization' \
--user 'CLIENT_ID:CLIENT_SECRET' \
--data-urlencode 'scope=openid profile email offline_access' \
--data-urlencode 'aud=https://api.example.com'
Authorization response
M7 returns a pending authorization with a 10-minute lifetime:
{
"device_code": "DEVICE_CODE",
"user_code": "ABCD-EFGH",
"verification_uri": "https://sso.user.m7.org/device_login",
"verification_uri_complete": "https://sso.user.m7.org/device_login?user_code=ABCD-EFGH",
"expires_in": 600,
"interval": 5
}
device_code is a secret. Keep it out of the user-facing display, logs, and
browser history. Show the user verification_uri_complete as a clickable
link, and also show user_code for manual entry.
Store the device authorization server-side for confidential clients. Store at least the device code, expiry, interval, and local workflow state.
User approval
The user opens verification_uri_complete in a normal browser, or visits
https://sso.user.m7.org/device_login and enters user_code. M7 collects the
necessary sign-in proof and approval. Your application does not call the
browser form-processing endpoints and must not collect M7 credentials.
If the consumer has enabled the Device Code two-factor setting, local password approval requires a current authenticator code or an accepted recovery code after the password succeeds. Existing sessions do not replace this fresh Device sign-in. Fresh federated approval follows its provider's authentication policy. Token pickup remains pending until required proof and approval finish; the polling contract does not change. See two-factor authentication.
Tenant password-based Device Code approval uses tenant password-factor enforcement, including the organization's main allowance. It does not use the independent consumer Device Code preference. Brokered/federated approval never requires local tenant 2FA. Browser-direct device/session listing is a separate app-session management surface, not a list of Device Code grants.
After password, two-factor, or provider authentication, a device request opens
a hosted consent page unless the account already has an active grant covering
all requested scopes and audiences. It shows the authenticated
account, application name and Client ID, user code, and requested permissions.
The user must choose Allow before an application without a covering grant can obtain tokens.
Authentication alone leaves polling at authorization_pending. Deny ends
the grant and polling returns access_denied.
The consent continuation is single-use and expires after five minutes or when the device grant expires, whichever comes first. A changed grant, account, registration, or disallowed scope invalidates the decision; start a fresh device authorization. Completed password-factor proof remains required through consent.
Poll for the token package
Poll /token no more frequently than the response's interval. Send the
same OAuth client authentication used to start the flow:
curl --silent --show-error \
--request POST 'https://sso.user.m7.org/token' \
--user 'CLIENT_ID:CLIENT_SECRET' \
--data-urlencode 'grant_type=device_code' \
--data-urlencode 'device_code=DEVICE_CODE'
For a public client, omit the secret and add client_id=CLIENT_ID to the form
body. M7 also accepts the standard grant value
urn:ietf:params:oauth:grant-type:device_code.
Before approval, M7 returns:
{
"error": "authorization_pending",
"error_description": "device authorization is still pending"
}
After approval, the response is the token package described in
Token endpoint. The successful pickup consumes
the device code. Stop polling on success, expiry, invalid_grant, or any
other terminal failure.
The selected audience set is sealed into the device grant. Polling /token
cannot replace it, and pickup fails if current client policy no longer allows
any member of the set.
The approved scope set is also sealed into the grant and rechecked against
current registration policy at pickup. A polling scope parameter cannot replace
it. Refresh retains the original approved scope ceiling and may request a subset.
Security and UX rules
- Follow
interval; do not aggressively poll. - Never display or ask the user to type
device_code. - Never put a client secret in the device UI, QR code, or browser code.
- Use an application-owned secure store for the returned refresh package.
- Apply the client's registered DPoP policy when polling
/token. Forrequired, every poll needs a new proof for the exact token URL andPOST; never reuse the proof from a priorauthorization_pendingresponse. - Retain the DPoP private key with the returned package when pickup creates a bound lineage; see DPoP status.
Organization scope
Register and explicitly request orgs to obtain it through device consent.
The permission authorizes a separate organization request;
it does not add organization claims to standard UserInfo or confer membership.
For /introspect/orgs, the current caller must still hold direct Management
membership, and each organization owner must permit disclosure to the receiving
service registration. Consent and orgs bypass neither check.