Start a device authorization - Spacefast Docs

Start a device authorization

Creates a device code and a user code, and returns the approval page a person opens to authorize the device. Poll POST /v1/auth/device/poll with deviceCode no faster than interval seconds, until expiresAt. The response also carries a requiresAction envelope whose continuation token drives the same wait through POST /v1/actions/resume. Send claim to attach an unclaimed Space, which the approver then assigns to one of their teams.

POST /v1/auth/device

Request body

Parameters

Responses

Try it

cURL Example

curl -X POST "https://api.spacefast.com/v1/auth/device" \
  -H "Content-Type: application/json" \
  -d '{
  "clientId": "spacefast-cli",
  "access": "read",
  "claim": {
    "spaceId": "string",
    "claimToken": "string"
  }
}'

JavaScript Example

const response = await fetch("https://api.spacefast.com/v1/auth/device", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: "{\n  \"clientId\": \"spacefast-cli\",\n  \"access\": \"read\",\n  \"claim\": {\n    \"spaceId\": \"string\",\n    \"claimToken\": \"string\"\n  }\n}"
});

Python Example

import requests

response = requests.post(
    "https://api.spacefast.com/v1/auth/device",
    headers={
        "Content-Type": "application/json"
    },
    data="{\n  \"clientId\": \"spacefast-cli\",\n  \"access\": \"read\",\n  \"claim\": {\n    \"spaceId\": \"string\",\n    \"claimToken\": \"string\"\n  }\n}",
)

Response Example

{
  "$schema": "http://example.com",
  "data": {
    "deviceCode": "string",
    "userCode": "string",
    "verificationUrl": "http://example.com",
    "interval": 9007199254740991,
    "expiresAt": "2019-08-24T14:15:22Z"
  },
  "requiresAction": {
    "actionType": "device_authorization",
    "instruction": "string",
    "url": "http://example.com",
    "pollUrl": "http://example.com",
    "continuationToken": "string",
    "pollAfterSeconds": 9007199254740991,
    "expiresAt": "2019-08-24T14:15:22Z"
  }
}

Error Example

{
  "$schema": "http://example.com",
  "type": "string",
  "title": "string",
  "status": -9007199254740991,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": [
    "string"
  ],
  "next": [
    "string"
  ],
  "requestId": "string"
}