Skip to end of metadata
Go to start of metadata

Introduction

The Login Widget provides user interface functionality to authenticate account owners or apstrata users registered under an apstrata account. Once the widget is placed in a web application page, it displays a form where a user can enter his credentials to login to the web application.

The "type" attribute of the widget specifies whether the widget is used to authenticate account owners or apstrata users.

Getting the code for the Apstrata SDK

ApstrataSDK code is available as open source from GitHub at https://github.com/apstrata/SDKs/tree/master/ApstrataSDK.

ApstrataSDK depends on the dojo 1.6 framework, you can download from here: http://download.dojotoolkit.org/release-1.6.1/dojo-release-1.6.1-src.zip

Installing the Apstrata SDK

  1. Unpack the dojo zip file into your web application
  2. Copy the ApstrataSDK into your web application
  3. Define where the ApstrataSDK is located by including the following code in your main web application page

    dojo.registerModulePath("apstrata", "<path to ApstrataSDK/apstrata subfolder>") 

Configuring the Apstrata Connection Parameters

You need to set the apstrata connection parameters in the file ApstrataSDK/apstrata/sdk/ApConfig.js to use you account authentication key and secret.

 

    "apstrata.sdk": {
        "Connection" : {
            credentials: {
                key: "<the authentication key of your apstrata account>",
            },
            serviceURL: '<the apstrata base URL, i.e. https://sandbox.apstrata.com/apsdb/rest>',
            timeout: <the connection timeout in milliseconds>
        }
    }

 

Embedding the widget in your web application

  1. Make sure to reference the dojo and apstrata core scripts and css files

    <script type="text/javascript" src="<relative path to dojo/dojo.js>" djConfig="parseOnLoad: true"></script>
    <script type="text/javascript" src="<relative path to ApstrataSDK/apstrata/sdk/apstrata.js>"></script>
    
    
    <style>
    	@import "<relative path to dojo/dijit/themes/claro/claro.css>";
    	@import "<relative path to ApstrataSDK/apstrata/ui/themes/apstrata/apstrata.css>";
    	@import "<relative path to ApstrataSDK/apstrata/ui/themes/apstrata/LoginWidget.css>";
    </style>
  2. Include the apstrata configuration file and the registration widget file

    dojo.require("apstrata.sdk.ApConfig")
    dojo.require("apstrata.ui.widgets.LoginWidget")
  3. Instantiate the registration widget and place it in your web application page

    //users authentication
    var lw = new apstrata.ui.widgets.LoginWidget({type: "user"})
    dojo.place(lw.domNode, dojo.body())
     
    //account owners authentication
    var lw = new apstrata.ui.widgets.LoginWidget({type: "master"})
    dojo.place(lw.domNode, dojo.body())

Example

Please refer to the file "ApstrataSDK/apstrata\ui/widgets/tests/test-Login.html" for a complete example on how to embed the widget

  • No labels