BITGO AUTHENTICATION GUIDE

The first step in using the BitGo SDK is acquiring an API access token. This token will authenticate your BitGo SDK requests with BitGo’s servers and give you access to all of the SDK’s functionality. This guide assumes you’ve already successfully created an account on test.bitgo.com, logged into your account, and followed the steps in our installation guide. BitGo’s test and production environment are equivalent, except that each has its own set of user accounts, and test.bitgo.com uses the testnet blockchain while bitgo.com uses the mainnet blockchain.

Starting out at the test.bitgo.com’s dashboard:

 

Click on the gear up in the top right corner next to your email address to go to the Settings page:

From the Settings page, click on the API Access tab, and then click on the Add Access Token button:

You’ll then be asked to enter information about what privileges/restrictions your access token should have. These are most useful when you need to share your token with another developer, but don’t want that developer having full access to the wallets on your account. Note that since we are using test.bitgo.com we do not have to give any values for the “IP Addresses Allowed” field, though when you make a production account you will need to whitelist the addresses your access token is allowed to send requests from. Add the following line to your ./bashrc file, or whichever shell initialization file your system uses:

export ACCESS_TOKEN="30fe66084b3eeb02c5f671d3a32452fa895d3c14436a4a98 e13b597dc96f689c"

Open a new window of your shell and run the following command to verify you’ve set your access token correctly:

$> echo $ACCESS_TOKEN

If you exported your token value correctly, you should see it printed out to the terminal screen. 

Now that you have your access token, you can programmatically authenticate yourself with BitGo’s servers using the BitGo SDK with the following two lines of code:

var BitGoJS = require('bitgo');
var bitgo = new BitGoJS.BitGo({ env: 'test', accessToken: process.env.ACCESS_TOKEN });
var BitGoJS = require('bitgo');
var bitgo = new BitGoJS.BitGo({ env: 'test', accessToken:
process.env.ACCESS_TOKEN });

Congratulations! You now have the full BitGo SDK’s functionality at your fingertips. If you'd like to unlock your access token for a prolonged period of time, you can use the Unlock API to have your session unlocked indefinitely.