I’m getting this message:
security has rejected access to method com.backendless.services.user.UserService.findByIdentity. see server log or contact system administrator
I’m getting this message:
security has rejected access to method com.backendless.services.user.UserService.findByIdentity. see server log or contact system administrator
Hi Omar,
What method do you invoke on the client side when you get this message?
Regards,
Mark
Backendless.UserService.findByIdentity("123456", new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser arg0) {
p=arg0.getEmail();
}
@Override
public void handleFault(BackendlessFault arg0) {
// TODO Auto-generated method stub
p=arg0.getMessage();
}
});
This is my code, 123456 is the identity of the user (not the objectId) and the message I get is as i mentioned before.
Is there another method that work and I can use? Or am I doing something wrong?
Thanks.
Hi Omar,
Please see the sample code below which accomplishes what you want. The “findByIdentity” method will be removed from the SDK.
package com.backendless.examples.userservice.demo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import com.backendless.Backendless;
import com.backendless.BackendlessCollection;
import com.backendless.BackendlessUser;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.exceptions.BackendlessFault;
import com.backendless.persistence.BackendlessDataQuery;
public class MainActivity extends Activity
{
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
Backendless.initApp( this, Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION );
BackendlessDataQuery dataQuery = new BackendlessDataQuery();
dataQuery.setWhereClause( "email = 'test@test.com'" ); //here "email" is the identity field name, and test@test.com is the identity value
Backendless.Data.of( BackendlessUser.class ).find( dataQuery, new AsyncCallback<BackendlessCollection<BackendlessUser>>()
{
@Override
public void handleResponse( BackendlessCollection<BackendlessUser> collection )
{
if(collection.getCurrentPage().isEmpty())
{
System.out.println("User with given identity not found");
}
else
{
BackendlessUser backendlessUser = collection.getCurrentPage().get( 0 );
Toast.makeText( getBaseContext(), "Found: " + backendlessUser.getEmail(), Toast.LENGTH_LONG ).show();
//do smth with user
}
}
@Override
public void handleFault( BackendlessFault backendlessFault )
{
Toast.makeText( getBaseContext(), backendlessFault.toString(), Toast.LENGTH_SHORT ).show();
}
} );
}
}
Thank you Mark that was really helpful !