thorz.js
npm package for Thorz
Usage
const tokenprocess = require('thorz').apiTokenProcess
gains access to the background API token processtokenprocess.start(options)
starts the background process that periodically fetches the OAuth token to access an API servertokenprocess.getToken()
gets the current OAuth token
Usage example
The following example sets up Thorz.js as a background process that periodically fetches the OAuth token for API access
const requestp = const tokenprocess = apiTokenProcess tokenprocessstart authorization_url: envTHORZ_AUTHORIZATION_URL client_id: envTHORZ_CLIENT_ID client_secret: envTHORZ_CLIENT_SECRET fetch_interval: 600 // every 10 minutes { // do some stuff // . // . // obtain data from API, using the token obtained from the tokenprocess let data = await // process the data obtained from API // . // .}