Creating Users

0 votes

I'm having trouble setting up the User Management, I did not have any luck with the User management page when I tried it, when ever I would run the game all the buttons and the text area would show but the text area would not type anything and all the buttons would throw a 401 error "unauthorized client" so I decided to try and change the code my self

using UnityEngine;
using UnityEngine.SocialPlatforms;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System;
using com.shephertz.app42.paas.sdk.csharp;
using com.shephertz.app42.paas.sdk.csharp.user;
using AssemblyCSharp;
public class NewUser : MonoBehaviour
Constant cons = new Constant ();
ServiceAPI sp = null;
UserService userService = null; // Initializing User Service.
User createUserObj = null;
public string success, txt_userName, txt_password, txt_emailId, box;
UserResponse callBack = new UserResponse ();
public GUIStyle typeFont; 
public GUIStyle labelFont;  
public GUIStyle buttonFont; 
public GUIStyle errorFont; 
float originalWidth = 1024; // Design resoultion
float originalHeight = 768;
public static bool Validator (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{return true;}
void Start ()
ServicePointManager.ServerCertificateValidationCallback = Validator;
sp = new ServiceAPI (cons.apiKey,cons.secretKey);
void OnGUI ()
// Set matrix
Vector2 ratio = new Vector2(Screen.width/originalWidth , Screen.height/originalHeight );
Matrix4x4 guiMatrix = Matrix4x4.identity;
guiMatrix.SetTRS(new Vector3(1, 1, 1), Quaternion.identity, new Vector3(ratio.x, ratio.y, 1));
GUI.matrix = guiMatrix;
GUI.TextArea (new Rect (10, 5, 300, 30), box, errorFont); 
if (Time.time % 2 < 1) {
success = callBack.getResult ();
// For Setting Up ResponseBox.
GUI.TextArea (new Rect (10, 5, 300, 30), success, errorFont);
GUI.Label (new Rect (10, 60, 100, 30), "E n t e r  u s e r n a m e", labelFont); 
txt_userName = GUI.TextArea (new Rect (10, 100, 440, 40), txt_userName, typeFont);
GUI.Label (new Rect (10, 160, 100, 30), "E n t e r  p a s s w o r d", labelFont);
txt_password = GUI.TextArea (new Rect (10, 200, 440, 40), txt_password, typeFont);
GUI.Label (new Rect (10, 260, 100, 30), "E n t e r  e m a i l", labelFont);
txt_emailId = GUI.TextArea (new Rect (10, 300, 440, 40), txt_emailId, typeFont);
string userName = txt_userName;
string password = txt_password;
string emailId = txt_emailId; 
if (GUI.Button (new Rect (50, 350, 300, 50), "Create User", buttonFont)) {
userService = sp.BuildUserService (); // Initializing UserService.
userService.CreateUser (cons.userName, password, cons.emailId, callBack);
// Reset matrix
GUI.matrix = Matrix4x4.identity;
this code makes three textfields for username, email, and password, i can type things in them but it throw the error email address is in valid what am I doing wrong? any help would be great! 
asked Jun 18, 2014 in App42 Cloud API-BaaS by rnvitter (22 points)

1 Answer

+1 vote
Best answer

Thanks for sharing the code snippet with us.

As i asuming you have passed the API key & Secret Key in Consatnt file.

Can you change the parameter userName & emailId which you have passed in Create User function.

Because what i have seen it looks like you are creating the text field but not pass the field values to function.

Function have taken the values from constant file that why emailId is not valid ezception occur.

answered Jun 19, 2014 by hs00105 (517 points)
selected Jun 19, 2014 by rnvitter
thanks for the feedback!

I'm confused on exactly how I would do this could you give me an example?
so i fixed the problem and now i get
Exception : com.shephertz.app42.paas.sdk.csharp.App42SecurityException: {"httpErrorCode":"401", "appErrorCode":"1401", "message":"UnAuthorized Access", "details":"Client is not authorized"}
Have you passed the APIKey and SecretKey which you have received after the app creation from AppHQ Management Console.
Also check the device time in which you are working is correct.
now it works thanks! must have been the device time
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on