I am in the process of releasing a mobile app that consumes data from an endpoint defined using services. I'd like to restrict the usage of the endpoint to the app, or at least make things more complicate for people wanting to use it.

I'd like to protect the endpoint with an API key hardcoded in my app, but without interfering with Drupal's user authentication. I haven't seen any module to do that: what would be the best hook to use for implementing this functionality?

Comments

falcon03 created an issue. See original summary.

falcon03’s picture

Issue summary: View changes
tyler.frankenstein’s picture

I've had luck with this contrib module: https://www.drupal.org/project/services_api_key_auth - With it I'm able to easily protect an endpoint with an API key.

falcon03’s picture

@tyler.frankenstein thanks for the suggestion. The problem with that module is that, if I understand correctly, it offers a mechanism based on user authentication. Thus you can't have an api key independent of any user plus standard user authentication where it is required. Am I right?

I'd like to protect parts of the endpoint that do not require user authentication such as the registration URI.

tyler.frankenstein’s picture

@falcon03

I'd like to protect parts of the endpoint that do not require user authentication such as the registration URI.

I currently use the module to have this exact protection, i.e. you can't hit the user registration service resource unless you have the api key.

jacob.embree’s picture

Status: Active » Fixed

Marking fixed because tyler.frankenstein's suggestion looks like it's sufficient.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.