Parents SDK

Info Contents
Version 2.0.0
Support devsupport@superawesome.tv
License GNU Lesser General Public License Version 3

Introduction

The Parents SDK is completely separate from the KWS SDK. It will help you develop apps aimed at parents, rather than their kids. It integrates with the SuperAwesome Parent Portal, including a Single Sign On (SSO) mechanism so that parents can log into your app through their Parent Portal account.

Including the sources in your html

<body>
    <!-- (...) -->

    <!-- KWS SDK -->
    <script type="text/javascript" src="https://parents-sdk.superawesome.tv/?v=2"></script>
</body>

Instantiating the SDK

Note

  • The current implementation only requires front-end SDK using implicit flow, just make sure you set the option implicit to true when instantiating the SDK.
// KWS will provide all the necessary info for your account
var parentsSdk = new KwsParentsSdk({
    // The client id of your application provided by SuperAwesome
    clientId: 'your_client_id',
    // The language of your front-end here
    language: 'en',
    // It will use the implicit flow
    implicit: true,
    // (optional) If set must contain the token of the parent. (useful when working with iframe)
    token: 'BEARER TOKEN HERE',
    // (optional) If set to true will will consider the backend as a different domain
    crossDomain: true,
    // (optional) Must contain the backend url if `crossDomain` is set to true
    callbackHost: 'https://yourbackendurl.com',
    // (optional) If using any environment different to production, indicate here
    env: 'staging',
    // (optional) If using a different domain for the SSO platform
    ssoUrl: 'https://singlesinonplatform.com'
});

Login or logout

If the parent is NOT logged in, you’ll want to display a login button; if the parent IS currently logged in, you’ll want to display a logout button instead. When you click on the button, this will call the action from the SDK to log in or log out.

<body>
    <button id="login" class="sa_sign_in" onclick="parentsSdk.signIn()"></button>
    <br/>
    <a href="#" id="logout" onclick="parentsSdk.signOut()">Logout (<span id="displayName"></span>)</a>
</body>
var parentsSdk = new KwsParentsSdk({
    clientId: 'your_client_id',
    implicit: true,
    language: 'en'
});

parentsSdk.app.parent.get()
    .then(function(parent){
        console.log('Got parent data', parent);
        document.getElementById('logout').style.display = 'block';
        document.getElementById('login').style.display = 'none';
        document.getElementById('displayName').innerHTML = parent.email;
    })
    .catch(function(){
        console.log('Call failed. parent is not authenticated');
        document.getElementById('logout').style.display = 'none';
        document.getElementById('login').style.display = 'block';
    })
    .finally(function(){
        console.log('This is always called at the end when the response is received');
    });

Get Parent Profile

This function allows you to get the parent’s profile

  • Function: app.parent.get

  • Parameters: none

  • Response:

    • id (Number): id of the user.
    • language (string) ISO 639-1 code.
    • dateOfBirth (string YYYY-MM-DD, optional). [1]
    • gender (string, optional) ‘m’ for male and ‘f’ for female. [1]
    • firstName (string, optional) [1]
    • lastName (string, optional) [1]
    • phoneNumber (string, optional) [1]
    • email (string, optional) [1]
    • streetAddress (string, optional) [1]
    • postCode (string, optional) [1]
    • city (string, optional) [1]
    • country (string, optional) [1]

    [1] This field will only be available if the corresponding permission is allowed.

  • Response example:

{
    "id": 2,
    "email": "parent@example.com",
    "dateOfBirth":"2005-03-07",
    "language":"en",
    "gender":null,
    "firstName":"",
    "streetAddress":"Example Street",
    "postCode":"11111",
    "city":"Example City",
    "country": "United Kingdom"
}
  • Example:
parentsSdk.app.parent.get()
    .then(function(parentData){
        // Your resp handler here
    })
    .catch(function(error){
        // Your resp handler here
    });