DrupalGap icon indicating copy to clipboard operation
DrupalGap copied to clipboard

How to set access with drupalgap system without drupal site user access permission?

Open ghost opened this issue 9 years ago • 1 comments

I create a callback url to my drupal site for update node count table base on nid. When user visit node details from android. I send ajax request to that url and count table update fine. since, my callback url is admin url like "example.com/admin/mymodule/update/2", i have to access anonymous to send this request.

But my problem is - how to set access with drupalgap system without drupal site user access permission?

ghost avatar Oct 25 '16 07:10 ghost

@tazimhossain I believe this module is what you're looking for: https://www.drupal.org/project/services_api_key_auth

It'll prevent anyone from accessing your Services without having an API key attached to the query string. In a custom DrupalGap module, use http://api.drupalgap.org/7/global.html#hook_services_preprocess to append the api key to each request coming from the app.

Also, I'd recommend updating the count on the server side when the node is retrieved, that way your app doesn't need to make an extra call to the server. You can do that using hook_services_request_postprocess_alter in a custom Drupal module (http://cgit.drupalcode.org/services/tree/docs/services.alter.api.php?h=7.x-3.x), which allows you to run custom code every time a node is retrieved (aka viewed) by the app.

signalpoint avatar Oct 25 '16 16:10 signalpoint