Once a user is created with the App42 platform, you can do user authentication in your app using just single line of code. Code snippet is shown below.
Following is the snippet to authenticate users with parameter username and password.
String userName = "Nick"; String pwd = "*******"; /*Following will throw App42Exception if authentication fails with error code 2002 in onException method otherwise onSuccess will get called */ userService.authenticate(userName, pwd, new App42CallBack() { public void onSuccess(Object response) { User user = (User)response; System.out.println("userName is " + user.getUserName()); System.out.println("sessionId is " + user.getSessionId()); } public void onException(Exception ex) { System.out.println("Exception Message : "+ex.getMessage()); } });NSString *userName = @"Nick"; NSString *pwd = @"*******"; User *user = [userService authenticate:userName password:pwd]; /* Above statement throws App42Exception if authentication fails with error code 2002 */public class Callback : App42Callback { String userName = "Nick"; String pwd = "*****"; userService.Authenticate(userName,pwd, this); // requestCallback points instance of App42Callback which overrides OnSuccess and OnException method void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { User user = (User) response; Console.WriteLine("userName is " + user.GetUserName()); Console.WriteLine("sessionId is " + user.GetSessionId()); } }String userName = "Nick"; String pwd = "*******"; User user = userService.authenticate(userName, pwd); /* Above statement throws App42Exception if authentication fails with error code 2002 */var userName = "Nick"; var pwd = "*********"; var result ; userService.authenticate(userName, pwd,{ success: function(object) { //Auth Success }, error: function(error) { //Auth Failed... } });String userName = "Nick"; String pwd = "*******"; User user = userService.authenticate(userName, pwd); /* Above statement throws App42Exception if authentication fails with error code 2002 */String userName = "Nick"; String pwd = "********"; userService.Authenticate(userName, pwd,new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { User user = (User) response; App42Log.Console("userName is " + user.GetUserName()); App42Log.Console("sessionId is " + user.GetSessionId()); } public void OnException(Exception e) { /* Above statement throws App42Exception if authentication fails with error code 2002 */ App42Log.Console("Exception : " + e); } }String userName = "Nick"; String pwd = "*******"; User user = userService.Authenticate(userName, pwd); /* Above statement throws App42Exception if authentication fails with error code 2002 */$userName = "Nick"; $pwd = "*******"; $response = $userService->authenticate($userName, $pwd); /* Above statement throws App42Exception if authentication fails with error code 2002 */userName = "Nick"; pwd = "*******"; response = userService.authenticate_user(userName, pwd); /* Above statement throws App42Exception if authentication fails with error code 2002 */var userName:String = "Nick"; var pwd:String = "*****"; userService.authenticate(userName,pwd, new callback()); public class callback implements App42CallBack { public function onException(excption:App42Exception):void { trace("Exception Message"); } public function onSuccess(response:Object):void { var user:User = User(response); trace("user response is : " + user); } }The request format for authenticate is URL : https://api.shephertz.com/cloud/1.0/user/authenticate Method : POST QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>×tamp=<UTC_FORMATED_TIME_STAMP> Accept : application/json Content-Type : application/json Body : { "app42": { "user": { "userName": "Nick", "password": "********" } } }