{"id":20829354,"url":"https://github.com/heftykoo/ding-token","last_synced_at":"2026-04-27T02:31:44.857Z","repository":{"id":129998624,"uuid":"113844060","full_name":"HeftyKoo/ding-token","owner":"HeftyKoo","description":"钉钉access_oken管理","archived":false,"fork":false,"pushed_at":"2017-12-26T04:03:04.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T11:00:18.460Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HeftyKoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-11T10:16:49.000Z","updated_at":"2020-04-07T09:36:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"24a4ccef-d8c5-4429-8ab6-8c18f708a436","html_url":"https://github.com/HeftyKoo/ding-token","commit_stats":null,"previous_names":["yeyuqiudeng/ding-token"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HeftyKoo/ding-token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeftyKoo%2Fding-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeftyKoo%2Fding-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeftyKoo%2Fding-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeftyKoo%2Fding-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HeftyKoo","download_url":"https://codeload.github.com/HeftyKoo/ding-token/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeftyKoo%2Fding-token/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32320238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T23:20:01.140Z","updated_at":"2026-04-27T02:31:44.780Z","avatar_url":"https://github.com/HeftyKoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ding-token\n\n\u003e 获取钉钉服务的access_token，可以同时管理多个access_token，会定时刷新token，避免过期。\n\n## Installation\n\n```javascript\nyarn add ding-token\n```\n\n## Usage\n\n```javascript\nconst DingToken = require('ding-token')\nconst dingToken = new DingToken({\n  list: [\n    {\n      name: 'test1',\n      corpid: '',\n      corpsecret: '', \n    }, {\n      name: 'test2',\n      corpid: '',\n      corpsecret: '',\n    }\n  ],\n  saveToken (token) {\n  \tdb.save(token)\n  },\n  onError (err) {},\n  onComplete (tokens) {console.log(tokens)}\n})\n```\n\n## 参数\n\n| 参数名        | 描述                                | 类型       | 回调参数   | 必填    |\n| ---------- | --------------------------------- | -------- | ------ | ----- |\n| list       | 需要管理的钉钉corpsecret                 | Array    | --     | true  |\n| saveToken  | token有更新时会触发的回调函数                 | Function | token  | false |\n| onError    | 获取token出错时触发的回调函数                 | Function | err    | false |\n| onComplete | 第一次获取所有token或者全部更新token完成时触发的回调函数 | Function | tokens | false |\n\n* list\n  * name: \u003cString\u003e 别名，必填\n  * corpid: \u003cString\u003e 钉钉的corpid，必填\n  * corpsecret \u003cString\u003e 钉钉的corpsecret，必填\n* saveToken (token)\n  * name \u003cString\u003e 对应token的别名\n  * corpid \u003cString\u003e 对应token的corpid\n  * corpsecret \u003cString\u003e 对应token的corpsecret\n  * errorcode \u003cNumber\u003e 错误码（0）\n  * errmsg \u003cString\u003e 错误信息（\"ok\"）\n  * access_token \u003cString\u003e access_token\n  * expire \u003cDate\u003e 过期日期\n\n## 方法\n\n### refresh（name）\n\n用来刷新指定的别名的 access_token。\n\n```javascript\ndingToken.refresh('test1')\n```\n\n### refreshAll()\n\n刷新所有的 access_token，如果所有 token 获取完成，会触发 `onComplete` 回调函数。\n\n```javascript\ndingToken.refreshAll()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheftykoo%2Fding-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheftykoo%2Fding-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheftykoo%2Fding-token/lists"}