The module ps_accounts is the interface between your module and PrestaShop's services. It manages:
If you need to install and test the module, you can download the desired zip here.
We aims to follow partially the Prestashop compatibility charts
ps_accounts version | Prestashop Version | PHP Version |
---|---|---|
7.x (unified) | >=1.6 && <9.x | PHP 5.6 - 8 |
6.x | >=8.0.0 | PHP 7.2 - 8 |
5.x | >=1.6 && <8.0.0 | PHP 5.6 - 7.4 |
If you are integrating a module, you should have a look on the PrestaShop Integration Framework Documentation.
Here are listed Open APIs provided by this module:
HTTP Verb | Controller | Method | Payload | Description |
---|---|---|---|---|
GET | AdminAjaxPsAccounts | getOrRefreshAccessToken | { token: " |
Return a token provided by Prestashop OpenId Connect Provider when the user has been authenticated by this provider |
Example: I want to get the authenticated user token in order make action on his behalf. The request would be GET https://<shop-admin-url>/index.php?controller=AdminAjaxPsAccounts&action=getOrRefreshAccessToken&ajax=true&token=<token>
where token
is a Prestashop Admin token.
Here are listed custom hooks provided with this module:
Hook name | Payload | Description |
---|---|---|
actionShopAccountLinkAfter | shopId, shopUuid | Triggered after link has been acknowledged by shop |
actionShopAccountUnlinkAfter | shopId, shopUuid | Triggered after unlink has been acknowledged by shop |
actionShopAccessTokenRefreshAfter | token | Trigger after OAuth access token has been refreshed |
All the tokens exposed follow the OpenId Connect Token and Access Tokens Specs.
This modules manages the following tokens:
JWT Name | Status | Description |
---|---|---|
Shop Token (legacy) | Deprecated 7.x | This token can be used to act as the shop. It should be used only for machine to machine communication without user interaction |
Shop Owner Token (legacy) | Deprecated 7.X | This token is created for the owner who associate the shop. |
Authenticated User Token | Introduced 6.x | ex: Backend Login with PrestaShop SSO |
OAuth Shop Access Token | Introduced 7.X | For machine to machine calls. (also used to keep up to date legacy Shop and Owner tokens). |
This module has three parts:
config/config.yml.dist
to config/config.yml
This repository has a Makefile. Just run for running phpunit make phpunit
and make phpstan
.
We use JWTs for 2 types of account: the user account and the shop account. What we're identifying when we link a PrestaShop shop is a shop. A shop belongs to 1 owner (user).
There are 2 Firebase projects:
use PrestaShop\PsAccountsInstaller\Installer\Installer;
use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts;
define('MIN_PS_ACCOUNTS_VERSION', '4.0.0');
$facade = new PsAccounts(new Installer(MIN_PS_ACCOUNTS_VERSION));
// Get or refresh shop token
$shopToken = $facade->getPsAccountsService()->getOrRefreshToken();
// Get or refresh shop owner token
$ownerToken = $facade->getPsAccountsService()->getUserToken();
see: PrestaShop Accounts Installer for more details on how to setup Installer.
This module don't use a .env file as a configuration file. We are now using YAML files with a Symfony service container to configure services and their injected dependencies as well as configuration parameters.
You can copy and paste the config.yml.dist
to config.yml
but you MUST NOT COMMIT THIS FILE
prestashop_accounts_auth
deprecatedThis library will be deprecated and no longer needed. Please remove it from your module's dependencies.
prestashop-accounts-installer
Do not directly import PrestaShop Accounts classes
If you need to call PrestaShop Accounts public classes's methods, you need to use the service container.
see: PrestaShop Accounts Installer
The ps_eventbus module is no longer installed automatically for Prestashop version <1.7.
Those API has been removed:
/carts
/categories
/deletedObjects
/googleTaxonomies
/apiHealthCheck
/info
/modules
/orders
/products
/themes