Skip to content

OAuth device flow

A sequence diagram. A TV app polls the auth server while the user approves on their phone, then calls the API.

A TV app polls the auth server while the user approves on their phone, then calls the APIA TV app polls the auth server while the user approves on their phone, then calls the API

Spec

oauth-device-flow.json
{
"type": "sequence",
"actors": [
{"id": "tv", "label": "TV App"},
{"id": "auth", "label": "Auth Server"},
{"id": "phone", "label": "User's Phone"},
{"id": "api", "label": "API"}
],
"interactions": [
{"from": "tv", "to": "auth", "label": "POST /device/code"},
{"from": "auth", "to": "tv", "label": "user_code + verify URL", "style": "dashed"},
{"from": "tv", "to": "auth", "label": "poll /token", "style": "async"},
{"from": "phone", "to": "auth", "label": "open verify URL"},
{"from": "phone", "to": "auth", "label": "enter user_code + approve"},
{"from": "auth", "to": "tv", "label": "access_token", "style": "dashed"},
{"from": "tv", "to": "api", "label": "GET /library (Bearer)"},
{"from": "api", "to": "tv", "label": "200 OK", "style": "dashed"}
],
"fragments": [
{
"type": "loop",
"over": ["tv", "auth"],
"sections": [{"label": "every 5s until approved", "start": 2, "end": 2}]
}
]
}

Draw it yourself

Terminal window
diago render oauth-device-flow.json > oauth-device-flow.svg

Open it in the playground to edit it in your browser.