Exchange a device code for a CLI credential
Polls the device authorization grant. Every answer is a 201 whose status says where the grant stands: pending (keep polling; reason: slow_down asks for a longer interval), failed (expired or denied — start again), or granted / granted-machine, which carries the credential exactly once.
POST
/auth/cli/device/tokenResponses
201Success.
One of:
object
statusstringrequiredreasonstringrequiredAllowed:
authorization_pendingslow_downobject
statusstringrequiredreasonstringrequiredAllowed:
expireddeniedobject
statusstringrequiredtokenstringrequiredmin length 1
grantIdstring<uuid>requiredaccountobjectrequiredShow propertiesHide properties
userIdstringrequiredemailstring<email>requirednamestring | nullrequiredteamsobject[]requiredShow propertiesHide properties
Array of
objectteamIdstring<uuid>requiredteamNamestringrequiredscopesstring[]requiredobject
statusstringrequiredtokenstringrequiredmin length 1
apiTokenIdstringmin length 1
grantIdstring<uuid>accountobjectrequiredShow propertiesHide properties
userIdstringrequiredemailstring<email>requirednamestring | nullrequiredteamobjectShow propertiesHide properties
teamIdstring<uuid>requiredteamNamestringrequiredprojectsstring[]min items 1
environmentsstring[]min items 1
teamsobject[]min items 1
Show propertiesHide properties
Array of
objectteamIdstring<uuid>requiredteamNamestringrequiredscopesstring[]requiredexpiresAtstring<date-time>required400The request failed validation. `field` names the offending input.
statusCodeintegerrequiredHTTP status code, repeated in the body.
min -9007199254740991 · max 9007199254740991
codestringrequiredStable machine-readable error code, e.g. `SECRET_NOT_FOUND` or `FORBIDDEN`. Branch on this, never on the message.
messagestringrequiredHuman-readable explanation. Wording may change.
fieldstringThe offending request field, present on validation failures.
401No credential was presented, or it is invalid or revoked.
statusCodeintegerrequiredHTTP status code, repeated in the body.
min -9007199254740991 · max 9007199254740991
codestringrequiredStable machine-readable error code, e.g. `SECRET_NOT_FOUND` or `FORBIDDEN`. Branch on this, never on the message.
messagestringrequiredHuman-readable explanation. Wording may change.
fieldstringThe offending request field, present on validation failures.
403The credential is valid but lacks the required scope, role or team access.
statusCodeintegerrequiredHTTP status code, repeated in the body.
min -9007199254740991 · max 9007199254740991
codestringrequiredStable machine-readable error code, e.g. `SECRET_NOT_FOUND` or `FORBIDDEN`. Branch on this, never on the message.
messagestringrequiredHuman-readable explanation. Wording may change.
fieldstringThe offending request field, present on validation failures.
404The resource does not exist, or is not visible to this credential.
statusCodeintegerrequiredHTTP status code, repeated in the body.
min -9007199254740991 · max 9007199254740991
codestringrequiredStable machine-readable error code, e.g. `SECRET_NOT_FOUND` or `FORBIDDEN`. Branch on this, never on the message.
messagestringrequiredHuman-readable explanation. Wording may change.
fieldstringThe offending request field, present on validation failures.
429Rate limited. Retry after the interval named in the response.
statusCodeintegerrequiredHTTP status code, repeated in the body.
min -9007199254740991 · max 9007199254740991
codestringrequiredStable machine-readable error code, e.g. `SECRET_NOT_FOUND` or `FORBIDDEN`. Branch on this, never on the message.
messagestringrequiredHuman-readable explanation. Wording may change.
fieldstringThe offending request field, present on validation failures.
500Unexpected server error. The body never carries internal detail.
statusCodeintegerrequiredHTTP status code, repeated in the body.
min -9007199254740991 · max 9007199254740991
codestringrequiredStable machine-readable error code, e.g. `SECRET_NOT_FOUND` or `FORBIDDEN`. Branch on this, never on the message.
messagestringrequiredHuman-readable explanation. Wording may change.
fieldstringThe offending request field, present on validation failures.
Request
curl -X POST "https://api.varsafe.dev/auth/cli/device/token"const response = await fetch("https://api.varsafe.dev/auth/cli/device/token", {
method: "POST"
});import requests
response = requests.post(
"https://api.varsafe.dev/auth/cli/device/token",
)Response
{
"status": "pending",
"reason": "authorization_pending"
}{
"statusCode": 0,
"code": "string",
"message": "string",
"field": "string"
}{
"statusCode": 0,
"code": "string",
"message": "string",
"field": "string"
}{
"statusCode": 0,
"code": "string",
"message": "string",
"field": "string"
}{
"statusCode": 0,
"code": "string",
"message": "string",
"field": "string"
}{
"statusCode": 0,
"code": "string",
"message": "string",
"field": "string"
}{
"statusCode": 0,
"code": "string",
"message": "string",
"field": "string"
}