Step 2: Authenticate him/herself
Objective
- Secure data exchanges.
I. Retrieving the keys
Retrieve your REST API keys:
- In the Settings > Shop menu, select your shop and go to the REST API keys tab.
Table of REST API keys :
For each use, there is a key for the TEST mode and a key for the PRODUCTION mode.
NUMBER | KEY NAME | Description |
---|---|---|
1 | User | For calls to REST Web Services |
2 | password | For calls to REST Web Services and to verify the authenticity of data returned in the IPN |
3 | Public key. | For creating a payment form in the Buyer's browser. |
4 | HMAC-SHA-256 Key | In order to verify the authenticity of the data returned during the payment form response in the browser |
This action is performed by a user who is authorized to manage keys and signing algorithms. Additionally, access to the REST API Keys tab requires specific functionality to be enabled. Please contact
More info: REST API keys.
II. Authentication phase
- Create a string with the user and the password separated by a colon (:)
- the username is the shop identifier: N° 1: user of the REST API key table
- thePassword, for example, for the test storetestpassword_q4JtCk2nuiMsl2hi1uU394oqQ5dB1sOoMMaS4k8SaiY00 : 2: REST API key table password
Encode the obtained chain in base64
Add the “Authorization” header to your request containing the word “Basic” followed by the string encoded in base64:
Authorization: Basic Njk4NzYzNTc6dGVzdHBhc3N3b3JkX0RFTU9QUklWQVRFS0VZMjNHNDQ3NXpYWlEyVUE1eDdN
For example, for PHP , the Authorization header will be calculated as follows:
$header = "Authorization: Basic " . base64_encode($username . ':' . $password);
Here is an example of a request. You can use the TEST SDK provided in the Playground to test your integration.
The complete HTTP request will resemble the image below. You can use the TEST SDK available via the Playground.
{ "value": "my testing value" }
III. Code samples
Code samples, in different languages , are available in GitHub.
IV. Simplified example in PHP
In the sample
folder, the file of this step is config.php. It allows you to define the authentication keys.
For more details, Example file: config.php.