장치 인증 부여
스마트 TV, 콘솔 및 CLI 도구처럼 입력이 제한된 장치가 보조 장치를 통해 토큰을 얻을 때 사용하는 OAuth2 장치 인증 부여(RFC 8628)를 학습합니다.
장치 인증 부여은(는) CoddyKit의 무료 OAuth2 & OpenID Connect Deep Dive 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 OAuth2 & OpenID Connect Deep Dive 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. OAuth2 & OpenID Connect Deep Dive 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Why a Device Grant?
Some clients have no browser or only a limited keypad: smart TVs, media consoles, printers, and CLI tools. The classic Authorization Code Flow assumes a rich browser for the user-agent redirect, which these devices cannot provide.
The Device Authorization Grant (RFC 8628) solves this by letting the user complete authorization on a second device (phone or laptop) while the constrained device polls for the result.
The Two Endpoints
The flow introduces a new device authorization endpoint alongside the standard token endpoint.
/device_authorization— the device requests codes here./token— the device polls here with grant typeurn:ietf:params:oauth:grant-type:device_code.
No redirect URI is involved at all.
Step 1: Requesting Device Codes
The device makes a POST to the device authorization endpoint with its client_id and desired scope.
POST /device_authorization HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
client_id=tv-app-123&scope=profile emailStep 2: The Response
The server returns a device_code (used by the machine), a user_code (typed by the human), a verification_uri, an expires_in, and an interval for polling.
{
"device_code": "GmRhmhcxhwAzkoEqiMEg",
"user_code": "WDJB-MJHT",
"verification_uri": "https://example.com/device",
"expires_in": 900,
"interval": 5
}Step 3: User Instructions
The device displays a short message: Go to example.com/device and enter code WDJB-MJHT.
A verification_uri_complete may also be returned, embedding the code so a QR code can carry the whole link.
Step 4: User Authorizes
On their phone or laptop, the user opens the verification URI, logs in, enters the user_code, and approves the requested scopes. This happens in a full browser, so MFA and rich consent screens all work normally.
Step 5: Device Polls the Token Endpoint
Meanwhile the device polls the token endpoint at the given interval, sending the device_code.
POST /token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:device_code
&device_code=GmRhmhcxhwAzkoEqiMEg
&client_id=tv-app-123Polling Responses
Until the user finishes, the server returns errors that tell the device how to behave:
authorization_pending— keep polling, user has not approved yet.slow_down— increase the interval by 5 seconds.access_denied— user rejected; stop.expired_token— codes expired; restart.
Step 6: Success
Once the user approves, the next poll returns a normal token response with an access_token (and optionally a refresh_token), exactly like other grants.
{
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "8xLOxBtZp8"
}A Simple Poll Loop
A pseudo-implementation of the polling logic, respecting slow_down:
let interval = 5;
while (true) {
await sleep(interval * 1000);
const res = await pollToken(deviceCode);
if (res.access_token) return res;
if (res.error === 'slow_down') interval += 5;
else if (res.error === 'authorization_pending') continue;
else throw new Error(res.error);
}Security Considerations
Keep user_codes short but high-entropy to resist brute force, and rate-limit the verification page. Because there is no redirect, phishing risk shifts to the verification URI — always show the user exactly which app and scopes they are approving.
Quick Check
Test your understanding of the device grant.
Recap
The Device Authorization Grant lets browserless devices authenticate users via a second device.
- Device gets a
device_code+user_codefrom the device endpoint. - User approves on a phone/laptop at the verification URI.
- Device polls the token endpoint, handling
authorization_pendingandslow_down. - On approval it receives normal access and refresh tokens.
자주 묻는 질문
“장치 인증 부여” 강의는 무료인가요?
네 — “장치 인증 부여” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 OAuth2 & OpenID Connect Deep Dive 강의 전체를 잠금 해제할 수 있습니다. OAuth2 & OpenID Connect Deep Dive 강의에는 총 4개의 강의가 포함되어 있습니다.
“장치 인증 부여”에서 뭘 배우나요?
스마트 TV, 콘솔 및 CLI 도구처럼 입력이 제한된 장치가 보조 장치를 통해 토큰을 얻을 때 사용하는 OAuth2 장치 인증 부여(RFC 8628)를 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 OAuth2 & OpenID Connect Deep Dive을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
OAuth2 & OpenID Connect Deep Dive을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 OAuth2 & OpenID Connect Deep Dive은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“장치 인증 부여” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 OAuth2 & OpenID Connect Deep Dive 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 OAuth2 & OpenID Connect Deep Dive 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.