---
title: "Device Authorization"
method: POST
path: "/api/v1/device_authorization"
tags: ["auth"]
---

# Device Authorization

`POST /api/v1/device_authorization`

OAuth2 device authorization endpoint.

This endpoint implements the OAuth2 device authorization grant flow as
defined in https://tools.ietf.org/html/rfc8628. It is called to initiate
the device authorization flow by requesting a device and user code for a
given client ID.

For a new client ID, a new OAuth device is created, stored in the DB and
returned to the client along with a pair of newly generated device and user
codes. If a device for the given client ID already exists, the existing
DB entry is reused and new device and user codes are generated.

Args:
    request: The request object.
    client_id: The client ID.

Returns:
    The device authorization response.

## Response `200`

Successful Response

- OAuthDeviceAuthorizationResponse — OAuth2 device authorization grant response.
  - `device_code` string, required
  - `user_code` string, required
  - `verification_uri` string, required
  - `verification_uri_complete` string, nullable
  - `expires_in` integer, required
  - `interval` integer, required

## Other responses

- `401` — Unauthorized
- `422` — Validation Error

---

[API](https://skmtc.net/zenml-io/apis/zenml-2.md) · [All operations](https://skmtc.net/zenml-io/apis/zenml-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/zenml-io/zenml-2/versions/febb01b8bce3/schema)
