authenticate and fetch additional data at the same time

0 votes

Hi Shephertz,

is it possible to fetch additional data with calling the authenticate function? I implemented the following and no json object is getting fetched:

        Query query = QueryBuilder.Build("email"emailOperator.EQUALS); 

        userService.SetQuery("EmailVerifications"query);    

        userService.Authenticate(username, password, new LoginCallBack(this));

    public class LoginCallBack : App42CallBack {  

        public void OnSuccess(object response){  
            User user = (User)response;
            for(int i=0i<user.GetJsonDocList().Counti++)  
            {  
                Debug.Log("json doc  is = "user.GetJsonDocList()[i].GetJsonDoc());   
            }         
        }  
        public void OnException(Exception e){  
        }  
    } 

cheers,

armin

asked Aug 18, 2015 in App42 Cloud API-BaaS by armin65 (39 points)
I have already added the json object at the time of user creation and it can be foundin AppHQ, login is successfull, but the additional data is not being fetched,

if I use userService.GetUserByEmailId(email,new UnityCallBack()); the data is being fetched. does this mean I have to call both functions or is there a way to this inside authenticate?

1 Answer

+1 vote
 
Best answer
Hello Armin,
 
Yes, it is possible in authenticating function as well. Please find a below code snippet for the same and let us know if it helps
String userName = "Nick"; 
String pwd = "********";
Dictionary<String, String> otherMetaHeaders = new Dictionary<String, String>();
otherMetaHeaders.Add("userProfile", "true");
App42API.Initialize("API_KEY","SECRET_KEY");
UserService userService = App42API.BuildUserService();
userService.SetOtherMetaHeaders(otherMetaHeaders);
App42API.SetDbName("<Enter_the_dbName>");
userService.SetQuery("<Your_Collection_Name>", query);   
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)
{
App42Log.Console("Exception : " + e);
}
}
 
Regards,
Himanshu Sharma
answered Aug 18, 2015 by hs00105 (2,005 points)
edited Jan 21, 2016 by hs00105
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
...