Skip to content

Latest commit

 

History

History
240 lines (204 loc) · 8.93 KB

File metadata and controls

240 lines (204 loc) · 8.93 KB

Platform Operation

This section describes how to use the Accounts and Template apps, demonstrating how to use GitHub as an identity provider to create your own blockchain-based account, and how to authorize access from another app.

Note
The following procedure assumes that you have performed the steps described in the Configure the Example and Run the Example Locally sections.

Create an account via GitHub OAuth

  1. Open the browser tab displaying the Accounts app.

    The URL for the Accounts app is http://localhost:3025.

    The Accounts app

  2. Open the browser’s developer tools and select the console tab.

    Verify that you see the interbit-middleware/CHAIN_BLOCKING status logged to the console for the accountsPrivate chain.

    The Accounts app with the browser’s developer console open

    Note
    If you do not see interbit-middleware/CHAIN_BLOCKING, but you do see interbit-middleware: reducer() Object, reload the page.

    The Interbit middleware prints a number of messages to the console so that you can see, for instance, when chains have loaded and actions have been dispatched. The Accounts app is fully up and running when you see the above message. At this point, you can dispatch actions to your accountsPrivate chain.

  3. Navigate to the create-account page by clicking on the Create Account / Sign in link in the page header. The Create account screen is displayed:

    The Create account screen in the Accounts app

  4. The Create Account button Click the Create Account button. A dialog appears with a disclaimer, asking you to confirm that you’re aware that the Interbit platform is experimental:

    The Interbit dialog

  5. The Create Account button Check the I acknowledge that I have read and understood this disclaimer checkbox, then click the Continue button. The GitHub authorization screen is displayed:

    The GitHub authorization screen

    Note
    If you are not already signed in to your GitHub account, you would see a GitHub login screen first.
  6. The GitHub Authorize button Review the request for access, then click the Authorize username button. Once the authorization is complete, the My Account screen is displayed:

    The My Account screen in the Accounts app

    When you see Signed-in at the right of the page header, you know that authentication is successful.

Congratulations! You have created an Interbit account. You can make changes to your personal account information and see how the new blocks are added to your accountsPrivate chain with each change.

Additional verification steps

  1. Verify that your user account information is on the private chain. Navigate to the Block Explorer page and expand the profile object property in the accountsPrivate chain.

    The Block Explorer screen in the Accounts app, showing the GitHub identity

    If you have not made any changes to your user profile information, you should see the that the name and gitHub-identity properties have values and that your GitHub profile information is stored in gitHub-identity.

  2. Verify that your user account information is not yet shared with any other apps by checking that the shared property in the accountsPrivate chain state is empty.

    The Block Explorer screen in the Accounts app, showing the shared status is empty

Allow the Template app to connect to your private account chain

Now that we have created a user account on the Accounts app, we can authorize the interbit-template app to read your name and email from your private accounts chain.

  1. Open the browser tab displaying the Template app.

    The URL for the Template app is http://localhost:3000.

    The Template app

  2. Open the browser’s developer tools and select the console tab.

    Verify that you see the interbit-middleware/CHAIN_BLOCKING status logged to the console for the templatePrivate chain.

    The Template app with the browser’s developer console open

    Note
    If you do not see interbit-middleware/CHAIN_BLOCKING, but you do see interbit-middleware: reducer() Object, reload the page.
  3. Verify that no data is shared on the templatePrivate chain.

    Navigate to the Block Explorer page and check that the sharedProfile property in the templatePrivate chain state is empty.

    The Block Explorer screen in the Template app, showing that no data is shared

  4. Click the Connect to Profile link in the header to navigate to the /cauth/request page.

    The Start the cAuth loop page in the Template app

  5. The Request cAuth button Click the Request cAuth button on the /cauth/request page.

    At this point, you are redirected to the Accounts app.

    The Accounts app’s authorization screen is displayed:

    The authorization screen in the Accounts app

    The templatePrivate chain is requesting a read join with the accountsPrivate chain for the name and email profile fields. Joins can be configured so that only specific fields are shared. Since the email field does not yet exist, you are given the opportunity to create and populate the field.

  6. Click the Add email link, enter an email address, then click the Save button.

    The email form in the Accounts app

    The authorization screen updates, and the Accept button becomes active:

    The authorization form in the Accounts app

    Using the browser’s developer console, you can verify that the accountsPrivate chain has a new block, and that the email address has been added to the profile.

  7. The Accept button Authorize the request for information by clicking the Accept button.

    At this point, you are redirected to the Template app.

    In the Template app and should see a message stating Complete the cAuth loop with a profile identifier of the form PROFILE-**.

    The Complete the cAuth loop screen in the Template app

  8. The Complete cAuth button Complete the chain authorization flow by clicking the Complete cAuth button.

    The button click dispatches an action to the templatePrivate chain and updates the state with the shared profile information.

Additional verification steps

  1. Verify that the templatePrivate chain state has the newly-shared profile information. Navigate to the Block Explorer and expand the sharedProfile property.

    The Block Explorer screen in the Template app, showing that the profile is now shared

    The name and email fields are populated with the values entered from the Accounts app.

    The accountsPrivate and templatePrivate chains are now joined. Whenever any updates to the user’s name or email occur in the Accounts app, these changes are automatically reflected in the templatePrivate chain.

  2. Verify that the chain join on the accountsPrivate chain. From the Block Explorer in the Accounts app, expand the shared property and check that there is an entry with the same profile identifier as in the authorization step.

    The Block Explorer screen in the Accounts app, showing the shared profile now contains populated data

Example complete

Congratulations! You have successfully completed this example. To recap, the example has demonstrated:

  • the structure of coordinated Interbit nodes and apps,

  • configuration of nodes and apps,

  • how to start nodes and apps,

  • how those coordinated nodes and apps work in practice.

Now that you have a working example, you have a foundation to tinker and learn further.