Logging Out Error 2202

0 votes

I am able to create users and log in but I do not think they ever actually log in, they just interact with the database because whenever I try to logout it throws a 2202 error

this is my log in script 

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 LogIn : 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;
 
#if UNITY_EDITOR
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;}
#endif
void Start ()
{
#if UNITY_EDITOR
ServicePointManager.ServerCertificateValidationCallback = Validator;
#endif
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 (250, 100, 100, 30), "E n t e r  u s e r n a m e", labelFont); 
txt_userName = GUI.TextArea (new Rect (250, 150, 550, 50), txt_userName, typeFont);
GUI.Label (new Rect (250, 220, 100, 30), "E n t e r  p a s s w o r d", labelFont);
txt_password = GUI.TextArea (new Rect (250, 270, 550, 50), txt_password, typeFont);
//GUI.Label (new Rect (250, 340, 100, 30), "E n t e r  e m a i l", labelFont);
//txt_emailId = GUI.TextArea (new Rect (250, 390, 550, 50), txt_emailId, typeFont);
 
string UserName = txt_userName;
UserName = cons.userName; 
string password = txt_password;
string email = txt_emailId; 
 
 
//========================================================================= 
if (GUI.Button (new Rect (250, 340, 300, 50), "Log In", buttonFont)) {
userService = sp.BuildUserService (); // Initializing UserService.
userService.Authenticate (UserName, password, callBack);
Application.LoadLevel ("menu"); 
}
 
// Reset matrix
GUI.matrix = Matrix4x4.identity;
 
}
}
 
 
does the problem have something to do with creating a session id? if so how would I go about doing this? would it be in my Log In script or a seperate script? sorry for all the questions, this type of stuff is very new to me. any help would be great! 
 
asked Jun 20, 2014 in App42 Cloud API-BaaS by rnvitter (22 points)

1 Answer

0 votes

If you are creating user or authenticating it, you will get the session id in return after success operation. This can be validated from following code. If you donet have valid session Id and trying to logout, it will throw 2202 error code. Please make sure that you are getting valid session Id.

userService.CreateUser(userName, pwd, emailId, new UnityCallBack());   
public class UnityCallBack : App42CallBack  
{  
 public void OnSuccess(object response)  
    { 
      User user = (User) response;  
      App42Log.Console("userName is " + user.GetUserName());  
      App42Log.Console("emailId is " + user.GetEmail());   
      App42Log.Console("Session Id is " + user.GetSessionId());   
    }  
}

 

answered Jun 21, 2014 by ajay123 (899 points)
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 support@shephertz.com
...