This section describes how to configure the example.
The Accounts app supports account creation and authentication via GitHub
only. In order to complete an OAuth flow with GitHub as the identity
provider, you need to create a new GitHub OAuth app and configure it to
connect to the web-auth-endpoint node.
-
Visit github.com and log into your account.
-
Navigate to Settings > Developer Settings > OAuth Apps.
-
Click the Register a new application button. The Register a new
OAuth application screen is displayed: -
In the Application name field, enter a name of your choice. For example,
Interbit Test App. -
In the Homepage URL field, enter a URL. Any URL works since we are running the example locally.
-
In the Authorization callback URL field, enter
http://localhost:8888/oauth/github.NoteThe callback URL is case sensitive, and the port specified is for running the web-auth-endpointnode locally. -
Click the Register application button to finish creating the OAuth
app.ImportantLeave this browser tab open as we are going to copy values from this tab in subsequent steps.
-
Open a terminal and clone the
interbitrepository from GitHub:git clone https://github.com/interbit/interbit.git
-
Install the
interbit-clipackage globally:npm i -g interbit-cli
-
Create a
secretsdirectory at the root of theinterbitrepository.The
secretsdirectory is included in this repository’s.gitignorefile and is not tracked by git. We don’t want to commit the files we are going to add here because they include private keys for our Interbit nodes. -
Change the current working directory to the
secretsdirectory:cd secrets -
Generate Interbit key pairs.
Both the
platform-deployandweb-auth-endpointapps require public and private keys. The following commands generate them and store them in JSON files:interbit keys --filename platform-deploy-keys.json interbit keys --filename web-auth-endpoint-keys.json
-
Create the file
platform-deploy.shin thesecretsdirectory with the following content:#!/bin/bash # Secrets for Accounts app GitHub OAuth chain export GITHUB_CLIENT_ID="" export GITHUB_CLIENT_SECRET="" export GITHUB_REDIRECT_URL="" export OAUTH_CALLBACK_URL="http://localhost:3025/account/oauth/gitHub" # Key pair for the platform node export PUBLIC_KEY="" export PRIVATE_KEY="" # Peer list override export PORT=5025 export CONNECT_TO_PEERS="localhost:8888"
-
Update the configuration in
platform-deploy.sh:-
Copy the
Client IDvalue from the GitHub browser tab and paste it into theGITHUB_CLIENT_IDdefinition inplatform-deploy.sh. -
Copy the
Client Secretvalue from the GitHub browser tab and paste it into theGITHUB_CLIENT_SECRETdefinition inplatform-deploy.sh. -
In the
GITHUB_REDIRECT_URLdefinition inplatform-deploy.sh, specify:http://localhost:8888/oauth/github. This should be the same URL provided in the Authorization callback URL field to the GitHub OAuth app configuration. -
Copy the
publicKeyvalue fromplatform-deploy-keys.jsonand paste it into thePUBLIC_KEYdefinition inplatform-deploy.sh. -
Copy the
privateKeyvalue fromplatform-deploy-keys.jsonand paste it into thePRIVATE_KEYdefinition inplatform-deploy.sh.
-
-
Save the updated
platform-deploy.shfile.
-
Create the file
web-auth-endpoint.shin thesecretsdirectory with the following content:#!/bin/bash # Secrets for Accounts app GitHub OAuth chain export GITHUB_CLIENT_ID="" export GITHUB_CLIENT_SECRET="" # Key pair for the web auth node export PUBLIC_KEY="" export PRIVATE_KEY="" # Peer list override export PORT=8888 export CONNECT_TO_PEERS="localhost:5025"
-
Update the configuration in
web-auth-endpoint.sh:-
Copy the
Client IDvalue from the GitHub browser tab and paste it into theGITHUB_CLIENT_IDdefinition inweb-auth-endpoint.sh. -
Copy the
Client Secretvalue from the GitHub browser tab and paste it into theGITHUB_CLIENT_SECRETdefinition inweb-auth-endpoint.sh. -
Copy the
publicKeyvalue fromweb-auth-endpoint-keys.jsonand paste it into thePUBLIC_KEYdefinition inweb-auth-endpoint.sh. -
Copy the
privateKeyvalue fromweb-auth-endpoint-keys.jsonand paste it into thePRIVATE_KEYdefinition inweb-auth-endpoint.sh.
-
-
Save the updated
web-auth-endpoint.shfile.
-
Navigate to the Accounts app directory:
cd ../packages/app-account -
Open the file
interbit.config.js. The first few lines of this file are:const path = require('path') const chainAliases = require('./src/constants/chainAliases') const { controlActionTypes } = require('./src/constants/actionTypes') const PUB_KEY = '' const WEB_AUTH_PUB_KEY = '' const config = { ...
-
Copy the
publicKeyvalue fromplatform-deploy-keys.jsonand paste it into thePUB_KEYdefinition ininterbit.config.js. -
Copy the
publicKeyvalue fromweb-auth-endpoint-keys.jsonand paste it into theWEB_AUTH_PUB_KEYdefinition ininterbit.config.js. -
Save the updated
interbit.config.jsfile.
-
Navigate to the Template app directory:
cd ../interbit-template -
Open the file
interbit.config.js. The first few lines of this file are:const path = require('path') const chainAliases = require('./src/constants/chainAliases') const PUBLIC_KEY = '' const config = { ...
-
Copy the
publicKeyvalue fromplatform-deploy-keys.jsonand paste it into thePUBLIC_KEYdefinition ininterbit.config.js. -
Save the updated
interbit.config.jsfile.
The manifest file must be deleted when new Interbit key pairs are generated, as we did in our setup. If there is a pre-existing manifest, the genesis blocks are not overwritten and our new keys do not work. Note that when we generate a new manifest, we create new genesis blocks which results in new chain IDs (which are hashes of the genesis blocks).
cd ../platform-deploy
rm platform/interbit.manifest.jsonAt this point, all of the apps are configured. See the
next section to see how to start the platform-deploy
and web-auth-endpoint nodes and the Accounts and Template apps.


