Webmecanik Pipeline has a documented public API on https://developers.webmecanik.com/pipeline.
Create an API key
The API key has the same permissions as the user holding the key.
To create you API key:
- Click the top right configuration menu
- Click the left API key submenu
- Click Add API key
- Fulfil the form and get your private and public key.
API Authentication
Find hereunder code snippets to grab the bearer token necessary to authenticate API by header Authorization.
The token must be prefixed by bearer, as following:
bearer Youkdjbfjkshvbksjdvjbjvcdjskvdsd321v51v6f5v1xc321x3v
PHP
$client_id = '018b90fc-db01-4b2f-xxxx-xxxxxxx';
$client_secret = 'Your secret';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pipeline.webmecanik.com/oauth/token");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'scope' => '*',
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => 'client_credentials'
));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Javascript
var request = require('request');
request({
url: 'https://pipeline.webmecanik.com/oauth/token',
mehtod: "POST",
form: {
scope: '*',
grant_type: 'client_credentials',
client_id: '018b90fc-db01-4b2f-xxxx-xxxxxxx',
client_secret: 'Your secret'
}
}, function(err, res) {
var json = JSON.parse(res.body);
console.log("Access Token:", json.access_token)
});
PHP avec HttpClient
use Symfony\Component\HttpClient\HttpClient;
$client_id = '018b90fc-db01-4b2f-xxxx-xxxxxxx';
$client_secret = 'Your secret';
$payload = [
'scope' => '*',
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => 'client_credentials'
];
$client = HttpClient::create();
$response = $client->request('POST', 'https://pipeline.webmecanik.com/oauth/token', $payload);
$data = $response->getContent();
js (ES6) with axios
import axios from 'axios';
const payload = {
scope: '*',
grant_type: 'client_credentials',
client_id: '018b90fc-db01-4b2f-xxxx-xxxxxxx',
client_secret: 'Your secret'
};
const uri = 'https://pipeline.webmecanik.com/oauth/token';
axios.post(uri, payload)
.then(res => {
console.log(res.data)
})
.catch(err => {
console.log(err)
});
Comments
0 comments
Please sign in to leave a comment.