training-token-generator v1.4.0
BYU-OIT Training Token Generator
Intro
This program is intended for students and employees at BYU-OIT to use in testing technical projects and other simple applications where inputting a token is used.
Install
npm install -g training-token-generator
Usage
There are a handful of ways to generate a token with this program.
The first is the most straightforward:
token
and you will be prompted to specify the environment, Client Id, and Client Secret (get client id/secret here). Then the token will be printed.
The second is faster. If you'd like to be able to quickly regenerate new sets of credentials from the command line, you can specify your environment, id, and secret as CLI arguments, in this order:
token [Environment] [Client Id] [Client Secret]
For example,
token dev cliend-id-here clientsecrethere
. If you pass your credentials in this way, you will not be prompted for them later and instead will just see a token printed out. If you would like, you can just specify one or two arguments (e.g. just Environment, or just Environment and Client Id) and the missing variables will be asked for in the program. Then the token will be printed.You can also pass these in as environment variables, named as follows:
stage
(for environment),clientId
, andclientSecret
. If both CLI args and env vars are used, CLI args will take precedence. If you would like, you can just specify one or two variables and the missing variables will be asked for in the program. Then the token will be printed.- You can pass in a fourth CLI argument to pre-select if you want the token copied to your clipboard. You can say 'yes', 'y', or 'true' (capitalization is ignored) to indicate that you would like to have it copied.
token [Environment] [Client Id] [Client Secret] yes
Your token will be valid for one hour after being generated. The time of expiration will be printed in the console below the token. You can (and should) reuse your token during that hour instead of generating a new one each time you need one.
Note: Environment names
When passing in the Environment/Stage parameter in as a CLI Argument or as an Environment Variable, here are the keywords that will be interpreted as 'Production' (capitalization doesn't matter):
- production
- prod
- prd
- stage
Anything else will be set the environment to 'Sandbox'.
Where to get credentials
If you don't already have a Client Id and Secret, you will need to make some. Generate a set of credentials at https://tcm.byu.edu. Make sure to select the correct environment for what you are doing. You are most likely going to be using a 'Sandbox' set of credentials. Also, make sure to record your Client Secret somewhere, this website will not save it for you.
Credentials are Secure!
These credentials are secure, so don't share them with anyone. To keep them out of commits and off of GitHub, don't ever hard-code them. Be careful when leaving them in IDE Run Configurations that those configurations are not tracked by GitHub