You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Next »
Example of receiving via Postman (pre-request script)
Download Postman - https://www.postman.com/
Run it
Create a new request
Choose method POST and put the URL
Example
https://{{authService}}/api/v2/OpenId/service/
![](https://wildix.atlassian.net/wiki/download/thumbnails/318603379/image-20231107-143157.png?version=1&modificationDate=1699367520523&cacheVersion=1&api=v2&width=736&height=97)
Copy Pre-request Script
Pre-request Script
const user = 'extension';
const pass = 'password';
const pbxHost = 'https://<domain>.wildixin.com';
const authService = 'auth.wildix.com';
pm.variables.set('authService', authService);
pm.sendRequest({
url: `${pbxHost}/api/v1/personal/token/?service=${authService}`,
method: 'GET',
header: {
'Authorization': 'Basic ' + btoa(`${user}:${pass}`)
},
body: {}
}, function(err, response) {
if (err || response.code !== 200) {
throw new Error('Personal token not received');
}
const personalToken = response.json().result.token;
console.log('PERSONAL TOKEN', personalToken);
pm.sendRequest({
url: `https://${authService}/api/v2/Token/`,
method: 'GET',
header: {
'Authorization': `Bearer ${personalToken}`
},
body: {}
}, function(err, response) {
if (err || response.code !== 200) {
throw new Error('Access token for auth not received');
}
const authAccessUserToken = response.json().result.accessToken;
console.log('AUTH ACCESS USER TOKEN', authAccessUserToken);
pm.variables.set('authAccessUserToken', authAccessUserToken);
});
});
Insert script to Postman
Go to the Authorization tab and choose the type and set dynamic variable:
Configure payload, see aud and scope in the documentation for services
{
"aud": "https://api.x-bees.com",
"scope": "xbees"
}
Insert payload to request
Make a request and receive a token.