mirror of
https://github.com/breath57/dingtalk-skills.git
synced 2026-09-14 20:51:31 +08:00
fix(dt_helper): use expires_in from API response for --old-token cache TTL
This commit is contained in:
@@ -190,6 +190,7 @@ cmd_old_token() {
|
||||
|
||||
resp=$(curl -s "https://oapi.dingtalk.com/gettoken?appkey=${app_key}&appsecret=${app_secret}")
|
||||
token=$(echo "$resp" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
|
||||
expires_in=$(echo "$resp" | grep -o '"expires_in":[0-9]*' | cut -d: -f2)
|
||||
|
||||
if [ -z "$token" ]; then
|
||||
echo "❌ 获取旧版 token 失败: $resp" >&2
|
||||
@@ -197,7 +198,7 @@ cmd_old_token() {
|
||||
fi
|
||||
|
||||
cfg_set DINGTALK_OLD_TOKEN "$token"
|
||||
cfg_set DINGTALK_OLD_TOKEN_EXPIRY "$((now + 7000))"
|
||||
cfg_set DINGTALK_OLD_TOKEN_EXPIRY "$((now + expires_in - 200))"
|
||||
|
||||
echo "$token"
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ cmd_old_token() {
|
||||
|
||||
resp=$(curl -s "https://oapi.dingtalk.com/gettoken?appkey=${app_key}&appsecret=${app_secret}")
|
||||
token=$(echo "$resp" | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
|
||||
expires_in=$(echo "$resp" | grep -o '"expires_in":[0-9]*' | cut -d: -f2)
|
||||
|
||||
if [ -z "$token" ]; then
|
||||
echo "❌ 获取旧版 token 失败: $resp" >&2
|
||||
@@ -197,7 +198,7 @@ cmd_old_token() {
|
||||
fi
|
||||
|
||||
cfg_set DINGTALK_OLD_TOKEN "$token"
|
||||
cfg_set DINGTALK_OLD_TOKEN_EXPIRY "$((now + 7000))"
|
||||
cfg_set DINGTALK_OLD_TOKEN_EXPIRY "$((now + expires_in - 200))"
|
||||
|
||||
echo "$token"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user