Skip to content

Authenticating with the API

Thomas edited this page Jul 23, 2018 · 6 revisions

Starting with version 0.3.0, external resources (users, clients, operators, external adapters, etc.) wanting to access a node's API will need credentials in order to pass authentication. These credentials are first created by the node operator upon the first run of the node. The operator will be presented with a prompt asking for an email and password.

Enter API Email: 
Enter API Password:

The password does not need to be your email account's actual password, but will be used for authenticating with the node with the given email address (like a username).

With the node running after successfully creating an API account, you should see a log similar to the one below:

2018-07-21T11:14:23Z [INFO]  API exposed for user myaccount@api.com      cmd/local_client.go:48

You can now create a text file to store your API account information for automating the startup process of the node. The text file should be two lines, the first being the email address, and the second line being the password. For example:

myaccount@api.com
mypassword

Then when running the node, you can specify the -a option with the path to the API account text file. For example:

$ chainlink n -a /home/$USER/.chainlink/.api

In another window and while the Chainlink node is running, you may receive the following error when trying to run chainlink commands, for example:

$ chainlink a
401 Unauthorized; Try logging in

The second terminal hasn't been authenticated with the API, so you will need to log in:

$ chainlink login
Enter email: thomas@smartcontract.com
Enter password:
$ chainlink a
╔ Account Balance
╬════════════════════════════════════════════╬══════════════════════╬══════════════════════╬
║                  ADDRESS                   ║         ETH          ║         LINK         ║
╬════════════════════════════════════════════╬══════════════════════╬══════════════════════╬
║ 0xEABB718Fa7A688Fc28f40700551721114955ff64 ║ 0.000000000000000000 ║ 0.000000000000000000 ║
╬════════════════════════════════════════════╬══════════════════════╬══════════════════════╬