user_id 和 secret。这些凭据在 Cobre 生态系统内提供,确保以安全且简便的方式访问平台。POST /auth
Content-Type: application/json
{
"user_id": "your_user_id",
"secret": "your_secret"
}{
"access_token": "eyJhbGciOiJSUzI1...",
"type": "Bearer",
"expiration_time": 1200
}Developers 部分。+ Create Credential。access_token 后请对其进行缓存。expires_in)tokenexpires_at = now + expires_in401 错误function getValidToken():
if cached_token exists AND now < cached_expires_at - safety_window:
return cached_token
lock(token_refresh_lock):
# Double-check after acquiring lock
if cached_token exists AND now < cached_expires_at - safety_window:
return cached_token
response = requestNewToken()
cached_token = response.access_token
cached_expires_at = now + response.expires_in
return cached_token