openfoodfacts / openfoodfacts-laravel

Open Food Facts API wrapper for Laravel
MIT License
148 stars 17 forks source link

Require a custom user agent to use the SDK #44

Closed teolemon closed 4 months ago

teolemon commented 1 year ago

What

Dwarfex commented 1 year ago

@teolemon - what exactly is the misuse? I'm afraid simply adding a user agent won't solve any essential misuse - and - would not help in contacting.

Who do you reach out to on a useragent like e.g. "PHP-SDK - Crawler"?

Dwarfex commented 1 year ago

Would't it be better to create personalized (organizational or independent) API keys?

epalmans commented 1 year ago

@teolemon this package is already doing this: https://github.com/openfoodfacts/openfoodfacts-laravel/blob/44ee0c288278d683b2bf4f6956e1ed53c337665b/src/OpenFoodFactsApiWrapper.php#L38

teolemon commented 1 year ago

@epalmans

@Dwarfex : for now, just personalized headers.

epalmans commented 1 year ago
  • Do we concatenate a custom part to the Laravel part ?

No. Currently, the user-agent value is populated with the name of the app the developer is using the package within. On default laravel installation this is "Laravel". As a fallback the value is set instead "Laravel Open Food Facts - https://github.com/openfoodfacts/openfoodfacts-laravel". However in practice, that latter shouldn't ever happen since the APP_NAME environment variabele is - as far as I am aware - always available and set in Laravel app's.

  • Is there a warning if no custom part is added ?

No, but it won't happen anyhow. See previous answer.

Dwarfex commented 1 year ago

@teolemon

what exactly is the misuse?

teolemon commented 1 year ago

It's not Laravel SDK specific, we're getting many search queries (and other) that don't make any sense for human usage, and it would be cool to have an idea of who is using the API.

epalmans commented 1 year ago

for the SDK's in general we could maybe introduce some kind of custom headers, like X-OFF-SDK (e.g. having a value of Laravel, Android, Ruby, whatever) along with X-OFF-SDK-VERSION to specify the SDK version no.