Contact Us 1-800-596-4880

Authentication to the Anypoint Platform CLI

To authenticate to Anypoint CLI, you must use one of the authentication option combinations:

  • Username and password

  • Client ID and client secret

  • Bearer token (command line only)

As a part of Multi-factor authentication (MFA) enablement for all users, starting October 2022, the only way to use Anypoint CLI will be through Connected Apps.

The default host, environment, and organization are used if you do not specify them.

Pass Anypoint CLI credentials by using the following methods:

Configuration settings are overridden as follows:

  • Command-line parameters override all other methods.

  • Environment variables are used if command-line parameters are not specified and override any credentials configuration file settings.

  • Credentials configuration file parameters are used if no command-line parameters or environment variables are set.

Set Credentials Using the Conf command

You can authenticate to Anypoint Platform by running the anypoint-cli-v4 command with the conf option to add your credentials to a configuration file and then running the anypoint-cli-v4 commands you want to use. You can set authentication values in the configuration file using a combination of the following parameters:

username
password
client_id
client_secret
host
session.selectedEnvironment.id
session.selectedOrganization.id

To create your configuration file:

  • Run the anypoint-cli-v4 conf command with the parameters you want to use to set the authentication method. For example, the following command sets the username and password.

    $ anypoint-cli-v4 conf username <username>
    $ anypoint-cli-v4 conf password <password>

The commands store the credential information in the config.json file in the following locations:

  • MacOS: ~/Library/Preferences/anypoint-cli-v4-nodejs/config.json

  • Windows: %APPDATA%\anypoint-cli-v4-nodejs\Config

  • Unix: ~/.config/anypoint-cli-v4-nodejs/

Examples:

  • Set configuration file authentication using username and password

    • Add authentication values to the configuration file using the following commands:

      $ anypoint-cli-v4 conf username myUserName
      $ anypoint-cli-v4 conf password myPassword
      $ anypoint-cli-v4 conf organization myOrgId
    • Run a command and the authentication will be done using the configuration file values.

      $ anypoint-cli-v4 account:environment:list
  • Set configuration file authentication using client ID and client secret

    • Add authentication values to the configuration file using the following commands:

      $ anypoint-cli-v4 conf client_id myClientID
      $ anypoint-cli-v4 conf client_secret myCLientSecret
      $ anypoint-cli-v4 conf organization myOrgId
    • Run a command and the authentication will be done using the configuration file values.

      $ anypoint-cli-v4 account:environment:list

      The organization flag is optional. It defaults to your main organization from Anypoint Platform.

You can get your client_id and client_secret via Connected Apps. For more information see Connected Apps for Developers.

Connected Apps require the View Organization and View Environment scopes to authenticate to Anypoint Platform.

Command-Line Parameters and Environment Variables

You can authenticate to Anypoint Platform through the command line by running the anypoint-cli-v4 command with a combination of parameters, or by setting a combination of the following environment variables before running the anypoint-cli-v4 command:

Command-Line Parameters Environment Variables

--username

ANYPOINT_USERNAME

--password

ANYPOINT_PASSWORD

--client_id

ANYPOINT_CLIENT_ID

--client_secret

ANYPOINT_CLIENT_SECRET

--bearer

-

--organization

ANYPOINT_ORG

--environment

ANYPOINT_ENV

-

ANYPOINT_CERTIFICATE

-

ANYPOINT_HOST

The --organization flag is optional. It defaults to your main organization from Anypoint Platform.

Examples:

  • Authenticate on the command line using username and password

    $ anypoint-cli-v4 account:environment:list --username myUserName --password myPassword --organization myOrgId
  • Authenticate on the command line using client ID and client secret

    $ anypoint-cli-v4 account:environment:list --client_id myClientID --client_secret myClientSecret --organization myOrgId
  • Authenticate on the command line using a bearer token

    You can generate a bearer token in Anypoint Platform and pass it to Anypoint CLI directly. When you provide a bearer token, Anypoint CLI ignores any provided user or client credentials.

    $ anypoint-cli-v4 account:environment:list --bearer myBearerToken --organization myOrgId

    Your Anypoint Platform session expires when the bearer token expires.

    For information about generating a bearer token, see How to Generate Your Authorization Bearer Token for Anypoint Platform.

  • Authenticate by setting the environment variables for username and password

    $ export ANYPOINT_USERNAME=myUserName
    $ export ANYPOINT_PASSWORD=myPassword
    $ export ANYPOINT_ORG=myOrgId
    $ anypoint-cli-v4 account:environment:list
  • Authenticate by setting the environment variables for client ID and client secret

    $ export ANYPOINT_CLIENT_ID=myClientID
    $ export ANYPOINT_CLIENT_SECRET=myCLientSecret
    $ export ANYPOINT_ORG=myOrgId
    $ anypoint-cli-v4 account:environment:list