Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to look at the current version, PrestaShop 8. Read the current version of the documentation
The Admin API is based on OAuth2 protocol which is widely used by many web actors.
Here’s a bit of generic terminology to help you understand the different components/actors in the OAUth2 protocol and their responsibilities:
Element | Description |
---|---|
Resource Owner | Entity that can grant access to a protected resource (usually the end user). |
Client | Application requesting access to a protected resource on behalf of the Resource Owner. |
Access Token | A token used to access protected resources |
Resource Server | Server hosting the protected resources capable of accepting and responding to requests using access tokens. |
Authorization Server | A server which issues access tokens after successfully authenticating a client and resource owner, and authorizing the request. |
Scope | A permission that grants access to one or several resources. |
JWT Token | Or JSON Web Token is a method for representing claims securely between two parties. |
Grant Type | The protocol has several types or workflow to validate authentication known as grant types (Authorization Code, Client Credentials, …) |
In the use case of the Admin API, here is how each element can be identified:
For “server-to-server” interactions, the recommended OAuth workflow is the client credentials workflow. The client is provided with a client ID and a client secret. The context of execution of the API is not as a user.
The operations made via this workflow will be associated to an application not a user.
The client is considered trusty so the workflow is simple and require very few steps.
The client credential workflow is quite simple, the client only needs to perform one request to the Authorization server, it needs to specify:
client_credentials
Keep in mind that the first request to get an access token already has to define the scopes (or permissions) that will be granted with the request access token. If you need to perform different API calls with different scopes, you must provide all the required scopes for all the subsequent calls.
It is recommended to use a limited subset of scopes in case your access token is stolen so that it only grants a few permissions.