-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add precisions on auth for apps (#10368)
Co-authored-by: Raphaël Odini <[email protected]> Co-authored-by: Alex Garel <[email protected]>
- Loading branch information
1 parent
56275c4
commit cb1e910
Showing
3 changed files
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,23 +74,29 @@ While testing your applications, **make all API requests to the staging environm | |
|
||
## Authentication | ||
|
||
We ask you to **always use a custom User-Agent to identify you** (to not risk being identified as a bot). The User-Agent should be in the form of `AppName/Version (ContactEmail)`. For example, | ||
We ask you to **always use a custom User-Agent to identify your app** (to not risk being identified as a bot). The User-Agent should be in the form of `AppName/Version (ContactEmail)`. For example, | ||
`MyApp/1.0 ([email protected])`. | ||
|
||
- READ operations (getting info about a product, etc...) do not require authentication other than the custom User-Agent. | ||
|
||
- WRITE operations (Editing an Existing Product, Uploading images…) **require authentication**. We do this as another layer of protection against spam. | ||
|
||
Create an account on the [Open Food Facts app](https://world.openfoodfacts.org/). From there, you have two options: | ||
Create an account on the [Open Food Facts app](https://world.openfoodfacts.org/) for your app (and notify [email protected] of the account name, so that we grant it special app privileges). From there, you have two options: | ||
|
||
- **The preferred one**: | ||
Use the login API to get a session cookie and use this cookie for authentication in your subsequent requests. However, the session must always be used from the same IP address, and there's a limit on sessions per user (currently 10) with older sessions being automatically logged out to stay within the limit. | ||
- If session conditions are too restrictive for your use case, include your account credentials as parameters for authenticated requests where `user_id` is your username and `password` is your password (do this on POST / PUT / DELETE requests, not on GET). | ||
|
||
You can create a global account to allow your app users to contribute without registering individual accounts on the Open Food Facts website. This way, we know that these contributions came from your application. | ||
|
||
We however ask that you send the [`app_name`, `app_version` and `app_uuid` parameters](https://openfoodfacts.github.io/openfoodfacts-server/api/ref-v2/#post-/cgi/product_jqm2.pl) in your write queries. | ||
* `app_name=MyApp` | ||
* `app_version=1.1` | ||
* `app_uuid=xxxx`: a salted random uuid for the user so that Open Food Facts moderators can selectively ban any problematic user without banning your whole app account. | ||
|
||
> Production and staging have different account databases, so **the account you create in the production environment will only work for production requests**. If you want to query (WRITE requests) the staging environment, you'll need to create another account there too. | ||
> Note: we're currently moving to a modern Auth system (Keycloak), so we will have new Auth options, hopefully this year. | ||
## Reference Documentation (OpenAPI) | ||
|
||
We are building a complete OpenAPI reference. Here is a list of the current API documentation available: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters