Getting Started

Getting Started with Node.js

Contents

Introduction

Verizon Personal Cloud Storage Node.js SDK allows you to develop apps which can access Verizon Personal Cloud Storage user content (subject to the user’s prior approva). It provides authentication and authorization for the apps.

Before You Begin

Before you can start coding, you will need to:

  1. Obtain Key, Secret, and Callback URL.
  2. Install and set up Node.js SDK.

1. Obtain Key, Secret, and Callback URL

Key, Secret, and Callback URL are established during registration. If you have not yet registered, follow the steps on the Getting Credentials to Use the Personal Cloud Storage APIs page in the API Developer Guide to register.

2. Install and set up Node.js SDK

Follow these steps to add the Verizon Personal Cloud Storage Node.js SDK to your project:

  1. Download Node.js SDK.
  2. To add the SDK to your project, include the cloud.js file in the <head> element of your webpage as follows:

    Code Sample

    <script src=“{{path to downloaded cloud file}}/cloud.min.js"></script>
    
    
  3. Initialize the SDK.

    Code Sample

    cloud.init({
        clientKey : "{{Key provided by Key Management}}",
        clientSecret : "{{Secret provided by Key Management}}",
        callbackUrl : "{{Callback URL you provided to Key Management when you registered your app}}",
            
        /* optional callback for when the SDK can begin making calls  */
        postInitialize : function(initted) {
            if(!initted) {
                console.log("could not initialize the API");
            }
        }
            
        /* optional callback for when a user has attempted to complete the authorization flow */
        postAuthenticated: function(success, errorCode) {
                
        },
            
        /* optional callback for when an authorization token expires or is revoked */
        onAuthInvalidated: function() {
            
        }
            
        }); 
    
  4. Use postInitialize function passed in the init method, or by wrapping your code in a jqeury-like ready handler, as shown in this example:

    Code Sample

    cloud.ready(function() { 
            // api is initialized 
        });
    

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.