A small utility to write your tokens to the file system to easily retrieve later
yarn add @node-cli-toolkit/save-tokenThere are two modes of usage:
You can easily save a token to the default storage location (in /tmp) and access it using
a unique identifier.
Examples of identifiers should look something like MY_APP_DROPBOX_API_TOKEN_USER_123. Remember to
make it as specific as possible because it may conflict with other tokens that are using
this tool. As a rule of thumb include:
- Name of your app
- Name of the token
- User ID/Email who the token belongs to
To save:
import { saveToken } from "save-token";
await saveToken({
tokenIdentifier: "TEST_TOKEN",
token: "I_AM_A_TOKEN"
});To retrieve do:
import { getToken } from "save-token";
const token = await getToken({
tokenIdentifier: "TEST_TOKEN"
});You can also specify a custom location for your file. This is useful if you have a existing storage directory.
To save:
import { saveToken } from "save-token";
await saveToken({
fileName: "/my/custom/location/TEST_TOKEN",
token: "I_AM_A_TOKEN"
});To retrieve do:
import { getToken } from "save-token";
const token = await getToken({
fileName: "/my/custom/location/TEST_TOKEN"
});