设备码轮询兑换 CLI 凭据(签发 PAT,与 POST /v1/api-keys 同形一次性回显,不再签会话票;pending 期间 400 device_code_pending;轮询过速 429 device_code_slow_down[RFC 8628,客户端间隔 +5s];approved 终态 CAS 一次性消费——凭据恒至多交付一次;PAT 存量上限同界 400 limit_exceeded;每 IP 认证严档)
POST
/v1/auth/device/token
const url = 'https://api.tansr.com/v1/auth/device/token';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"deviceCode":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tansr.com/v1/auth/device/token \ --header 'Content-Type: application/json' \ --data '{ "deviceCode": "example" }'Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
deviceCode
required
string
Examplegenerated
{ "deviceCode": "example"}Responses
Section titled “Responses”CLI 凭据(一次性回显)
Media typeapplication/json
object
key
required
一次性回显的完整 PAT(tansr_sk_…);库存 sha256
string
Example
{ "apiKey": { "status": "active" }}Device_code_pending / device_code_expired / limit_exceeded
Media typeapplication/json
object
error
required
object
code
required
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
string
message
required
string
requestId
required
string
detail
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}Device_code_denied
Media typeapplication/json
object
error
required
object
code
required
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
string
message
required
string
requestId
required
string
detail
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}Device_code_slow_down(轮询过速)/ rate_limited(每 IP 认证严档,T-A28)
Media typeapplication/json
object
error
required
object
code
required
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
string
message
required
string
requestId
required
string
detail
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}本文是否有帮助?
感谢反馈,我们会持续改进这篇文章。