Manage Projects
Manage projects and switch between them to create related resources.
Affinidi CLI is a developer tool to easily manage your projects and integrate with Affinidi services using the command line. It empowers developers to use simple commands to improve developer experience when interacting with our different services.
Affinidi CLI is an open-source tool, and you can access the GitHub repository here .
Install NodeJS v18 or higher on your machine.
Install Git to generate a reference app using affinidi generate app command.
Accessing most Affinidi CLI features, like creating a Login Configuration, requires you to authenticate to Affinidi using Affinidi Vault. To do this, you can execute the following command:
affinidi start
If you received a session expired
error, just run the same command to refresh your session.
Commands in Affinidi CLI have the following structure:
affinidi <topic> <command> [flags]
affinidi
.affinidi help <topic|command>
to show the helpful details.Explore the Affinidi CLI topics to manage your projects, including Login Configurations to integrate Affinidi Login into your application.
Below are some of the useful commands available to access Affinidi services.
affinidi start
Log in to Affinidi
Log in to Affinidi
USAGE
affinidi start [--json] [--no-color] [--no-input]
GLOBAL FLAGS
--json
Format output as json.
--no-color
Disables color in the output. If you have trouble distinguishing colors, consider using this flag.
--no-input
Disables all the interactive prompts
EXAMPLES
affinidi start
affinidi stop
Log out from Affinidi
Log out from Affinidi
USAGE
affinidi stop [--json] [--no-color] [--no-input]
GLOBAL FLAGS
--json
Format output as json.
--no-color
Disables color in the output. If you have trouble distinguishing colors, consider using this flag.
--no-input
Disables all the interactive prompts
EXAMPLES
affinidi stop
affinidi whoami
Returns user’s subject, projects, and token details from the current session.
Returns user’s subject, projects, and token details from the current session.
USAGE
affinidi whoami [--json] [--no-color] [--no-input]
GLOBAL FLAGS
--json
Format output as json.
--no-color
Disables color in the output. If you have trouble distinguishing colors, consider using this flag.
--no-input
Disables all the interactive prompts
EXAMPLES
affinidi whoami
affinidi help
Display help for affinidi.
Display help for affinidi.
USAGE
affinidi help [COMMANDS] [-n]
ARGUMENTS
COMMANDS Command to show help for.
FLAGS
-n, --nested-commands
Include all nested commands in the output.
DESCRIPTION
Display help for affinidi.
affinidi search
Search for a command.
Search for a command.
USAGE
affinidi search
DESCRIPTION
Search for a command. Once you select a command, hit enter and it will show the help for that command.
affinidi commands
list all the commands
list all the commands
USAGE
affinidi commands [--json] [-h] [--hidden] [--tree] [--columns [value] | -x] [--sort [value]] [--filter [value]] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
FLAGS
-h, --help
Show CLI help.
-x, --extended
show extra columns
--columns=[value]
only show provided columns (comma-separated)
--csv
output is csv format [alias: –output=csv]
--filter=[value]
filter property by partial string matching, ex: name=foo
--hidden
show hidden commands
--no-header
hide table header from output
--no-truncate
do not truncate output to fit screen
--output=[option]
output in a more machine friendly format [options: csv|json|yaml]
--sort=[value]
property to sort by (prepend ‘-’ for descending)
--tree
show tree of commands
GLOBAL FLAGS
--json
Format output as json.
DESCRIPTION
list all the commands
affinidi autocomplete
display autocomplete installation instructions
display autocomplete installation instructions
USAGE
affinidi autocomplete [SHELL] [-r]
ARGUMENTS
SHELL (zsh|bash|powershell) Shell type
FLAGS
-r, --refresh-cache
Refresh cache (ignores displaying instructions)
DESCRIPTION
display autocomplete installation instructions
EXAMPLES
affinidi autocomplete
affinidi autocomplete bash
affinidi autocomplete zsh
affinidi autocomplete powershell
affinidi autocomplete --refresh-cache
All commands and topics have a help document with usage, descriptions, flags and examples.
View it with the help flag: affinidi login create-config --help
With the help root command: affinidi help login create-config
Or by searching and selecting a command: affinidi search
All commands have some global flags at their disposal.
--help
Prints the command’s help information.
--json
Enforce printing the output in json format. Useful for programmatic usage of CLI.
--no-color
Disables color in the output. Useful if you have trouble distinguishing colors.
--no-input
Disables all the interactive prompts. Useful for automation anc ci.
You can input flags in multiple ways. All of the following will work:
affinidi login create-config --file="config.json"
affinidi login create-config --file "config.json"
affinidi login create-config --file=config.json
affinidi login create-config --file config.json
affinidi login create-config -f "config.json"
affinidi login create-config -f="config.json"
affinidi login create-config -f"config.json"
affinidi login create-config -f config.json
affinidi login create-config -f=config.json
affinidi login create-config -fconfig.json
Affinidi CLI introduces a local concept of “Active Project” for convenience. Commands under the login
and iam
topics perform actions under the active project. In order to not have to ask for the project and create the necessary credentials each time you call one of these commands, we ask you to define the CLI’s working project once.
To check what is the current active project use the command affinidi project get-active-project
To switch the active project use the command affinidi project select-project
When you authenticate to Affinidi with affinidi start
the CLI will create a folder with a credentials file in your home directory.
~/.affinidi/credentials-v2.json
- Stores your current session credentials. Keep it secret as this allows you to call Affinidi services.
When you run affinidi stop
your session information is deleted.
Manage projects and switch between them to create related resources.
Manage your Login Configuration, and user groups to integrate Affinidi Login.
Manage your Personal Access Token (PAT) to connect and perform actions on Affinidi services on the user’s behalf.
Manage your IAM policies to grant access to users and Personal Access Tokens (PATs).
Generate sample apps using different programming languages, frameworks, and IAM solutions.
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.