Reputation: 466
When I try to save QBCustomObject
, response from server sometimes it says
Base forbidden. Need User.
Before saving, I checked QBChatService.getInstance().isLoggedIn()
and it returns true.
This error happens for both:
Disappears after re-launching the app and signing in process.
HashMap<String, Object> fields = new HashMap<String, Object>();
fields.put("name", name);
fields.put("User ID", currentUser.getId());
QBCustomObject qbCustomObject = new QBCustomObject();
qbCustomObject.setUserId(currentUser.getId());
qbCustomObject.setClassName("Group");
qbCustomObject.setFields(fields);
QBCustomObjects.createObject(qbCustomObject, new QBCallbackImpl() {...});
Here are the chain of actions which leads to creating QBCustomObject
:
QBAuth.createSession() -> QBUsers.signIn() -> QBChatService.getInstance().loginWithUser()
Why does this error happen?
Upvotes: 2
Views: 2964
Reputation: 107
create your session with QBUser.
ex :- QBAuth.createSession(new QBUser("user_name", ""))
Upvotes: 0
Reputation: 466
Seems like I've found the bug. I didn't used the QBUser
object I got from .signIn()
response. Here is what I mean:
QBUsers.signIn(user, new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
if (result.isSuccess()) {
QBUser signedInUser = (((QBUserResult) result).getUser());
signedInUser.setPassword(password);
//...
loginToChat(signedInUser);
//...
}
});
Upvotes: 4
Reputation: 18346
Chat login and login to Application - they are different logins.
In order to create any object in QuickBlox (except a chat message) - you must act on the user's behalf
More info here how to create a record http://quickblox.com/developers/SimpleSample-customObjects-android#Create_record_using_Android_SDK
There you will find a link how to login a user to application http://quickblox.com/developers/SimpleSample-users-android#Sign_In_.26_Social_authorization
Upvotes: 3