Cordova – authenticate

/*
 *  Authenticate a Bluedot Point session.
 *  The success function call provides an error code and an optional string for any warnings after successful
 *  authentication.
 *      An error code of 0 entails no additional warnings.
 *  The fail function call provides a string with the reason for failure.
 */
exports.authenticate = function( success, fail, username, apiKey, packageName )
{
    exec( success, fail, "BDPointSDK", "authenticate", [ username, apiKey, packageName ] );
}

Description

This function is utilised to start an authenticated session with Point SDK.  The credentials are returned from creating an App on the Bluedot Point Access web site; further information can be read in the Point Access User Guide.

Parameters

success (Function)

This is a function that will be called on successful authentication with the Bluedot Point Access back-end.  This entails which a current authenticated session is now underway; an app only has to be authenticated once for the entire runtime of the app.

On occasion, successful authentication can return a warning to notify the app that there is something to be aware of.  This is passed back as an error code and warning message.

Function parameters

Integer – Error code. This code will be zero if there are no issues during authentication; if there is an issue to be aware of (for example, on an Android device, Wi-Fi has been switched off), then this code is returned here.

String – A warning message with a description of the error code.

fail (Function)

This is a function that will be called if authentication with the Bluedot Point Access back-end fails.

Function parameters

String – Reason for authentication failure.

username (String)

The username is part of the credentials returned from registering with the Bluedot Point Access web site.

apiKey (String)

The API Key is part of the credentials returned from creating an app on the Bluedot Point Access web site; an API Key is associated with each app that you create.

packageName (String)

The Package Name is part of the credentials returned from creating an app on the Bluedot Point Access web site; a Package Name is associated with each app that you create.

Notes

You can obtain the credentials for each app after registering and logging in to the Point Access web site.  The details can be accessed following the information provided in Point Access – Creating a new app.

/*
 *  A delegate function for dealing with successful authentication.
 *  If authentication was successful but has an issue, then this is passed back to the app with
 *  an associated message.
 */
function authenticationSuccessful( errorCode, message )
{
    if ( typeof message === "undefined" || errorCode == 0 )
    {
        updateStatus( "Authentication successful" );
    }
    else
    {
        updateStatus( "Authentication successful but " + warning );
    }
}
 
/*
 *  A delegate function for dealing with a failed authentication.
 */
function authenticationFailed( error )
{
    updateStatus( "Authentication failed: " + error );
}
Created by Bluedot DevOps on January 16, 2018

Start the discussion