Giter Club home page Giter Club logo

wwtoken's Introduction

自动更新的企业微信令牌

本模块只干一件事,定期自动获取企业微信令牌并缓存至Redis。

全局安装

npm i wwtoken -g

新建配置文件

{
  "redis": "redis://127.0.0.1:6379",
  "logsDir": "wwtoken-logs",
  "configs": [
    {
      "corpid": null,
      "corpsecret": null,
      "token_key": "wwtoken_access_tokenA",
      "token_expires": 7000,
      "ticket_key": "wwtoken_jsapi_ticketA",
      "ticket_expires": 7000
    },
    {
      "corpid": null,
      "corpsecret": null,
      "token_key": "wwtoken_access_tokenB",
      "token_expires": 7000,
      "ticket_key": "wwtoken_jsapi_ticketB",
      "ticket_expires": 7000
    }
  ]
}

Tips: 支持JavaScript和JSON两种配置,当不指定配置文件参数时,会自动识别当前执行目录下的config.jsconfig.jsonwwtoken.config.jswwtoken.config.json.wwtokenrc这几个文件名作为配置文件。

支持的配置项

  • redis:Redis的连接地址,按照ioredis的规范指定配置即可
  • logsDir:日志存放目录,执行目录下的相对路径或绝对路径皆可
  • configs:配置数组部分
  • corpid:企业ID
  • corpsecret:应用的凭证密钥,每个应用有独立的secret,所以每个应用的access_token应该分开来获取
  • token_key:令牌数据缓存在Redis的键,必填参数,默认wwtoken_access_token
  • token_expires:令牌自动刷新的间隔秒数,可选参数,目前企业号令牌过期时间为7200秒,默认7000秒获取一次接口并刷新缓存
  • ticket_key:JSAPI票据数据缓存在Redis的键,可选参数
  • ticket_expires:JSAPI票据自动刷新的间隔秒数,可选参数,默认7000秒获取一次接口并刷新缓存

启动模块

wwtoken -c` <config_path>

使用令牌

当每次需要使用令牌时,直接通过上面设置的key从Redis中获取即可,获取的值即为令牌数据。

传送门

wwtoken's People

Contributors

rubikplanet avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

rubikplanet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.