Try replacing
KiiAnonymousUser.create()
with
new KiiAnonymousUser()
It seems the static create() method has been removed.
Best
Question
I'm testing Kii Cloud mobile backend as a service (MBaaS) in an Android application. I'm trying to create an object in an application level bucket before any user authentication takes place. For that I want to modify the app bucket to allow anonymous users to write to it:
Kii.initialize("my_app_id", "my_app_key", Kii.Site.US);
KiiBucket bucket = Kii.bucket("app_status");
KiiACL ubACL = bucket.acl();
ubACL.putACLEntry(new KiiACLEntry(KiiAnonymousUser.create(), KiiACL.BucketAction.CREATE_OBJECTS_IN_BUCKET, true));
ubACL.save(new KiiACLCallBack() {
@Override
public void onSaveCompleted(int token, KiiACL acl, Exception exception) {
if (exception != null)
Toast.makeText(getInstance().getApplicationContext(), exception.toString(), Toast.LENGTH_LONG);
}
});
But I always get an exception when trying to save the ACL (onSaveCompleted() returns with an exception):
com.kii.cloud.storage.exception.ACLOperationException: Error: null
HTTP Response Status: 403
HTTP Response Body: {
"errorCode" : "WRONG_TOKEN",
"message" : "The provided token is not valid",
"appID" : "bc4100c0",
"accessToken" : "null",
"suppressed" : [ ]
}
I'm passing my app_id and app_key correctly in the beginning (first line of sample code). Any ideas what could be causing this error? Thanks in advance for your answer.
Solution
Try replacing
KiiAnonymousUser.create()
with
new KiiAnonymousUser()
It seems the static create() method has been removed.
Best
OTHER TIPS
Answering my own question. My code snippet for sure will cause exceptions because custom access control via ACL can only be applied to group and user level buckets (not app level buckets)