You can import the sdk as a JS build:
or with npm:
npm install --save kano-world-sdk
var config =API_URL : ''WORLD_URL : '';var KW_SDK = config;
To initialise the SDK, run:
There are a few ways to enable login with Kano World - the first one with the use of a button, or any element with the attribute
<!-- Pressing the following button will prompt you to authorise this domain to login with Kano World. If the user logs in successfully, the SDK will pick it up and enable logged in features. -->Login with Kano World
Once logged in, you can display a button or HTML element to logout with the attribute
<!-- Pressing the following button will log the user out. -->Logout
init method on the SDK takes a callback that will be triggered once the user completed authentication. The callback will be fired in case of success or failure, in which case it will contain an error.
Otherwise, you can now used logged in features and methods, and the API calls made throught
KW_SDK.api.* will use the user's credentials.
If you need to access the user object in any other moment, you can use the
If you want to trigger the login on Kano World via code instead of using the button attribute, you can call:
KW_SDKauth;// This method will redirect to Kano World and come back after authentication complete.
Also, you can logout by calling:
KW_SDKauth;// This method will forget your token and refresh.
Once logged in, the app storage module allows you to access and change profile stats into a specific app namespace of your profile, without seeing any of the rest.
Use it like this:
You can register custom elements for login/register forms. These forms will take care of the field validation and authentication and trigger events to notify when login/register/errors occurs.
You can register these elements like so:
You will then be able to use them in your HTML pages.
Display a complete login form. Usage:
Display a complete register form. Usage: