android - cloudBackend.setCredential not setting createdBy/updatedBy/owner properties of CloudEntity -


I am using the mobile backend starter and when trying to update an entity while using safe by id settings I am here. I'm getting the error

  com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized {"code": 401, "Errors": [{"domain": " Global "," location ":" authorization "," location type ":" header "," message ":" irreversible permission to update cloud entity: CE: 123456: USER: 123456 "," reason ":" required "} ], "Message": "Irreversible Permission to Update CloudEntity: CE: 123456 By: USER: 123456"}   

Documents () states

Code below, come backend client Allows to call in safe by ED ???? Mode It automatically sets the / updateB / owner properties created by CloudEntity

  GoogleAccountCredential credentials = GoogleAccountCredential.usingAudience (this, "& lt; Web Client IDs & Gt; "); Credential.setSelectedAccountName ("& lt; Google Account Name";); CloudBackend.setCredential (Credential);   

So I wrote the following code

mCloudBackend = New CloudBackendMessaging (this);

  GoogleAccountCredential Credential = GoogleAccountCredential.usingAudience (this, Consts.AUTH_AUDIENCE); MCloudBackend.setCredential (Credential); String account name = Mclodbackend.getShearePrint (). GetString (Consts.PREF_KEY_ACCOUNT_NAME, blank); Credential.setSelectedAccountName (of account); MCloudBackend.setCredential (Credential); NewPost.setId (updateRide); MCloudBackend.update (newPost, Handler); Unfortunately, this is giving up the error though, going through the update because I can see the changes in the unit when I ask on behalf of the datastore. The problem comes from the fact that the built / updated / owner is set to free the assets and therefore are not being set automatically  

I have seen other questions where The first unit of the update is answered to query, use it to set the above properties and then update. I try to avoid this because this datastore looks like an unnecessary call. So my question is how do I prepare GoogleAccount and update the owner properties?

I encountered a similar problem playing with a mobile backend starter source. And although I did this Regarding the answers given about, I did not solve the issue. However, what I did was to capture the mobile backend source code and to make some modifications. Hold the code and in the CrudOperations.java file, you will see this method Private map & lt; String, unit & gt; Find and update existing components (EntityListDto CDL, user user) throws unauthorized expressions {// Existing ID EntityListDto Make a list of CES with entities with Ids = new EntityListDto (); Maps & lt; String, Antidata & gt; IDmap = new hashmap with entities & lt; String, Antidata & gt; (); (EntityDto cd: cdl.getEntries ()) {if (cd.getId ()! = Null) {entitiesWithIds.add (CD); IIMMap with institutions Input (cd.giid (cd)); }} // Existing CES map & lt; String, unit & gt; Try to get it. Existing Antives = Millatititiklist (Institutions Withdays .readKeyList (Users)); // Update for existing entities (String ID: Existing antiquities.ket ()) {// Check ACL Entity E. - Existing Entities. SecurityChecker.getInstance () CheckAclForWrite (e, user); // Update Metadata EntityDto cd1 = entitiesWithIdMap.get (id); Cd1.setUpdatedAt (new date ()); If (user! = Null) {cd1.setUpdatedBy (user.getEmail ()); } // Update the entity cd1.copyPropValuesToEntity (e); } Existing current returns;

}

From the code given above, comment securitycake .get instance (). CheckAclForWrite (e, user); and unauthorized exceptions throws lines and recruits your backend. Doing so enables all users of your app to update related unit. If you are worried about strictly owned, then it can be risky. So, consider your safety concerns before taking this approach. Heaven has done this, now you can update the related cloud unit freely. Remember your new backup backup on the server side by default.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -