Authenticate A User

To authenticate a user for a Session, invoke the authorize() function with the username you are requesting authorization for.

Definition

authorize(username)

Parameters

username:String Platform User username, user push ID, or end-user identifier for the user
transactional:Boolean Is the current request for a transaction versus a user Session.
pushId:Boolean Return the user push ID, a value uniquely and permanently identifying the Platform User associated with the a service, with the response.

Session Example

mAuthManager.authorize("username", false, pushId, new AuthenticationManager.AuthorizeCallback() {
    @Override
    public void wasSuccess(final String userHash, final String authRequest, final String userPushId, final String deviceId) {
        //Success block
        //Note: Remember to keep hold of the authRequest string as you will use it later to reference this session
    }

    @Override
    public void wasFailure(final String errorMessage, final String errorCode) {
        //Failure block
    }
}

To authorize a user for a transaction, invoke the authorize function and set the transactional flag to true. Set the pushId flag to true if you want the push notification id back in the callback. The fourth argument being the authorize callback.

Transaction Example

mAuthManager.authorize("username", true, pushId, new AuthenticationManager.AuthorizeCallback() {
    @Override
    public void wasSuccess(final String userHash, final String authRequest, final String userPushId, final String deviceId) {
        //success block
    }
    @Override
    public void wasFailure(final String errorMessage, final String errorCode) {
        //failure block
    }
});

This will send an authentication request to the user. Once the user has successfully authorized the request, the wasSuccess block will be called and will return the user hash, auth request, app pins and device ID. If an error occurs, the wasFailure block will be called and will include an error code </developer/api/message-codes> and message indicating what went wrong.

Returns - Successful

userHash:Unique string used to identify the user in the future
authRequest:Used to identify the Auth Request in subsequent requests
userPushId:A value uniquely and permanently identifying the Platform User associated with the a service.
deviceId:User device identifier

Returns - Failed

Click here for an explanation of error codes.

errorMessage:Error message
errorCode:Code used to identify error type

User Contributed

LaunchKey links to user contributed code as a resource to its community. LaunchKey does not in any way guarantee or warrant the quality and security of these code bases. User contributed code is supported by the creators. If you do find a link from the site to user contributed code that is malicious or inappropriate in any way, please report that link to LaunchKey immediately and we will investigate the claim. Submit any issue to LaunchKey support at https://launchkey.com./support. ×