Realtime Cloud Storage
Connecting

  • Feb 27, 2015
  • Starting Guide

To start using Realtime Cloud Storage you just need to obtain your free application key at https://accounts.realtime.co/signup/

After you register and subscribe the Realtime Cloud Storage service you can obtain your application key and private key using the Web Console by clicking the details link on your subscription:

You’ll find your application key and private key at the right of your screen as shown in the following picture:

Whenever you need to connect to your Realtime Cloud Storage you’ll need to use your application key. The private key is only used for authentication purposes, so you can authenticate your user’s tokens to define their permissions, but for simplicity we’ll cover that later in the Security chapter.

To connect to your Realtime Cloud Storage you need to create a StorageRef (aka as Storage Reference). You can easily do it in JavaScript like this:

 

<!-- Include the Realtime Cloud Storage JavaScript library from the CDN -->

<script type='text/javascript' 
src='https://storage-cdn.realtime.co/storage/1.0.0/realtime-storage-min.js'></script>

<script type='text/javascript'>

    var storageRef;
    // Define your credentials and security mode
    var credentials = { 
      applicationKey: "[YOUR_APP_KEY]",   // Your application key
      authenticationToken: "userToken",   // When auth is off it can be anything
      isSecure: true                                // Use SSL connection               
    };

    Realtime.Storage.create(
    credentials, 
        function(ref) {
            storageRef = ref;   // Keep the Storage Reference for later usage
            startApp();         // Start using your Cloud Storage       
        },
        function(error){
            console.log(“Error connecting to the Storage”, error);
        }
    );

</script>

From this point on, in the code examples, we’ll assume you already have included the JavaScript library from the CDN and already have a valid Storage Reference kept in the storageRef variable.

For more details check out the Realtime Cloud Storage documentation at http://framework.realtime.co/storage/#documentation

NOTE: By default a Realtime Cloud Storage free application key doesn’t have authentication enabled, meaning that any request will be allowed. Naturally this is cool when you’re developing and trying features for the first time, but please remember that you should always turn the authentication on at least when your project goes into production. Please refer to the security chapter of the documentation to know how you can easily turn the authentication on using the Web Console.

Back to Main Concepts or proceed to Working with tables

If you find this interesting please share: