Setup API connection
Information required to setup connection
- Operator access to Back-Office
- API url
- API client secret
- API client id
Create API user through Back-Office
- Connect to Back-Office as operator
- Go to user menu
- Create a user
- Add operator role to this user
- Set the user password
Test your API user through Postman
You could test your api user through Postman by clicking here
Use your access token to make your first request
The access token must be provided in each request that need authentication. It must be passed as Authorization header. A user can belongs to several user groups (operator / seller / customer), so you also must provide the context header that is the user group id who execute the request. If you're making the request as operator, you must set '1' for this parameter.
PHP script example to setup API connection
Here is an example script on how to make request to Origami API with PHP and Guzzle
<?php
use GuzzleHttp\Client;
$access_token = '';
$base_url = '';
$client_id = 2;
$client_secret = 'secret';
$user_email = 'email';
$user_password = 'password';
$context = 1;
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'context' => $context
];
$params = [
'client_id' => 2,
'client_secret' => $client_id,
'grant_type' => 'password',
'username' => $user_email,
'password' => $user_password
];
$client = new Client();
$response = $client->request('post', '/oauth/token', ['form_params' => $params, 'headers' => $headers]);
$headers['Authorization'] = 'Bearer '.json_decode($response->getBody()->getContents())->access_token;
$response = $client->request('get', '/v1/catalog/categories/1', ['headers' => $headers]);
You can find endpoints list by clicking here