User Management Service

Almost every app requires User Management, at the simplest level Registration and Authentication. The App42 APIs provides a comprehensive User Management solution to handle users both as App42 Users and Social Users. The service contains operations for managing user creation, authentication, state (revoking, locking, expiry etc.), role management, profile management, password policy, etc. Almost everything that one can do is available through the AppHQ console. These users can be also exported in various formats at the click of a button, if required.

User Management service is designed to be orthogonal. Other App42 services can be used independently of this service, they are not connected or dependent. It can also be integrated with existing CRM, LDAP, Active Directory, etc.
This module also works in conjunction with App42 Marketing Automation which provides comprehensive actionable analytics on user’s behavior and the ability to take action e.g. Push Notification, In-App Message, Social Post, Email, Survey, Coupon, Lead Generation, NPS (Net Promoter Score) etc. With App42 MA you can track funnels and cohorts, through which action can be taken as campaigns or on demand.

Along with User Management, the library provides APIs for persistent Session Management across Omni-Channel devices that help in maintaining context based sessions across.

In order to use the various functions available in a specific API, a developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the application was created. secretKey - The secret key corresponding to the application key given when the application was created.

After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that you wish to build. For example, to build an instance of UserService, buildUserService() method needs to be called.

UserService userService = App42API.buildUserService();

UserService userService = App42API.BuildUserService();

UserService *userService = [App42API buildUserService];

let userService = App42API.buildUserService() as? UserService

UserService userService = App42API.buildUserService();

UserService userService = App42API.BuildUserService();

var userService = new App42User();

local userService = App42API:buildUserService()

UserService *userService = App42API::BuildUserService();

UserService userService = App42API.BuildUserService();

$userService = App42API::buildUserService();

UserService *userService = App42API::BuildUserService();

user_service = api.build_user_service

var userService:UserService = App42API.buildUserService();

Coming Soon

UserService userService = App42API.buildUserService();

Create User

This function allows you to create a User session for the specified User. Note: Username and EmailId should be unique for the App.

Required Parameters

userName - Name of the user for whom the user session is to be created. pwd - Password of the user. emailId - EmailId of the user.

Lock the user based on the username. Your app can use this feature to lock a user because of reasons specific to their use case. For example, if payment is not received and the app wants the user to be inactive.

Unlock the previously locked user based on the username. Your app can use this feature to lock a user because of reasons specific to their use case. For example, if payment is received and the app wants the user to be active.

Delete a particular user based on username. Note: From this method, you can only soft delete the user. If you want to delete the user permanently, you can do so in two ways
1. Delete from AppHQ console management.
2. Set the “deletePermanent” flag true in otherMetaHeaders. See Delete User Permanent.

This function allows you to create a user session for the specified User and add their profile. Note: Username and Email ID should be unique for the App.

Required Parameters

userName - Name of the user whose user session is to be created. pwd - Password of the user. emailId - Email ID of the user. profile - Add all the values that you want to retain in user profile object.

local App42CallBack = {}
local otherMetaHeaders = {};
otherMetaHeaders.like= "n"; // To get the list of users whose name start from "n"
App42API:initialize("API_KEY","SECRET_KEY")
local userService = App42API:buildUserService()
userService:setOtherMetaHeaders(otherMetaHeaders);
userService:getAllUsers(App42CallBack)
function App42CallBack:onSuccess(object)
if table.getn(object) >1 then
for i=1,table.getn(object) do
print("UserName is "..object[i]:getUserName())
print("Email id is "..object[i]:getEmail())
end
else
print("UserName is "..object:getUserName())
print("Email id is "..object:getEmail())
end
end
function App42CallBack:onException(exception)
print("Message is : "..exception:getMessage())
print("App Error code is : "..exception:getAppErrorCode())
print("Http Error code is "..exception:getHttpErrorCode())
print("Detail is : "..exception:getDetails())
end

Fetch all the list of users who has a specific value in their profile e.g If you want to fetch the list of users whose first name start from “Nick” and last name start from “Gill” using below code snippet.

Required Parameters

profileData - Profile Data key/value for which Users need to be retrieved.

The functions available under User API can throw some exceptions in abnormal conditions. For example, If a developer is creating a user with a username which is already in the database, the function will throw the App42Exception (as shown below) with the message as “Bad Request” and the appErrorCode as “2001” and the details as “The request parameters are invalid. Username ‘Nick’ already exists”.

Functions in User API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):

1400 - BAD REQUEST - The requested parameters are invalid 1401 - UNAUTHORIZED - Client is not authorized. 1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again 2000 - NOT FOUND - User by the name '@userName' does not exist. 2001 - BAD REQUEST - The request parameters are invalid. Username '@userName' already exists. 2002 - NOT FOUND - UserName/Password did not match. Authentication Failed. 2003 - BAD REQUEST - Old Password is not matching for user '@userName'. 2004 - NOT FOUND - User with the emailId '@emailId' does not exist. 2005 - BAD REQUEST - The request parameters are invalid. User with emailId '@emailId' already exists. 2006 - NOT FOUND - Users do not exist. 2007 - NOT FOUND - The number of users are less than the specified offset 2008 - NOT FOUND - The number of locked users are less than the specified offset 2009 - NOT FOUND - Users with the role '@role' do not exist. 2010 - NOT FOUND - No role found for the user '@userName'. 2011 - NOT FOUND - Role '@role' for the user '@userName' does not exist. 2012 - NOT FOUND - Roles for the user '@userName' do not exist.