Realm CLI Authenticate With API Token


MongoDB provides the Realm Command Line Interface (realm-cli) to manage your Realm apps programmatically. You can authenticate a MongoDB Cloud User with an API key for your project. Generate an API key through the access manager in your MongoDB Cloud account.

Generate an API Key


Configure Your API Whitelist

Copy your Private Key to a safe location for later use. For security, the Private Key will not be visible again after initialization. Another security feature is API Whitelisting. Creating an API Whitelist ensures that API calls originate from whitelisted IPs.

The IP Address of the user who will be using the API Key is required to use the key. Click the Add Whitelist Entry button to whitelist an IP address. Type in the IP Address or click the Use Current IP Address buttton and click save. Finally, click the done button on your screen’s lower right-hand to finish setting up your API key.

Authenticate with an API Key


Authenticate a CLI User

Using your newly created public and private key, log in by running the command below.

realm-cli login --api-key="<my api key>" --private-api-key="<my private api key>"

You should see the following result:

you have successfully logged in as <your public key>