Affinidi CLI

Manage your projects and integration using command line interface.

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 .

Before you begin
  1. Set up Affinidi Vault account. Follow the guide below if you haven’t set it up yet.
Set up Affinidi Vault
  1. Set up an Affinidi Vault account using the web app or install the mobile app .

The same installation steps for mobile app.

  1. Click on Start if you are creating a new account, or click on Restore from Backup if you have an existing backup of your Affinidi Vault.

Use this guide to learn how to migrate your existing Affinidi Vault account.

Affinidi Vault Setup
  1. Secure your Vault by providing a passphrase. Use this passphrase to unlock your Vault.
Affinidi Vault Passphrase
  1. Provide your Email Address to verify with OTP.
Affinidi Vault Email Verification

After successfully providing the OTP, you are redirected to your Affinidi Vault dashboard.

  1. Install NodeJS v18 or higher on your machine.

  2. Install Git to generate a reference app using affinidi generate app command.

Installation

How do I use Affinidi CLI?

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.

Understanding commands

Commands in Affinidi CLI have the following structure:

affinidi <topic> <command> [flags]
  1. All commands start with the keyword affinidi.
  2. Topics typically correspond to Affinidi services or domains.
  3. Commands correspond to the actions to perform.
  4. Flags are a way to provide the parameters required by the command.
  5. Use affinidi help <topic|command> to show the helpful details.

Available commands

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

affinidi start

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

affinidi stop

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.

affinidi whoami

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.

affinidi help [COMMANDS]

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

affinidi 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

affinidi autocomplete [SHELL]

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

Help

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

Flags

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

Active Project

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

Session and Configuration Files

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.

Explore CLI Topics and Commands


Manage Projects

Manage projects and switch between them to create related resources.

Manage Login

Manage your Login Configuration, and user groups to integrate Affinidi Login.

Manage Token

Manage your Personal Access Token (PAT) to connect and perform actions on Affinidi services on the user’s behalf.

Manage IAM

Manage your IAM policies to grant access to users and Personal Access Tokens (PATs).

Generate App

Generate sample apps using different programming languages, frameworks, and IAM solutions.