# Yealink Management Cloud Service(YMCS)_User Guide.pdf - Pages 861-880

**Source:** Yealink Management Cloud Service(YMCS)_User Guide.pdf
**Pages:** 861-880 of 953
**Chunk:** 44

---

 Yealink Management Cloud Service(YMCS) U...




3.Set the APP Secret.




4.Obtain the Client ID (APP ID) and Tenant ID.




                                                 46 / 108
  Yealink Management Cloud Service(YMCS) U...




Configure on YMCS
1. Create an Azure application
1. Enter "https://portal.azure.com" in the address bar of your computer's browser to access
  the Azure portal.
2. Click Azure Active Directory > Manage > App registrations and select New registration.
3. Edit account information and save.
  Name: Edit the name users see when logging in using the App.
  Supported account types: Select which types of account logins the app can be used for.
  Redirect URI (optional): When the authentication is passed, Microsoft will send the Token
  to this address.
4. After completing the application creation, obtain the Application (client) ID/Secret of the
  application.

2. Obtain access token
Using the OAuth 2.0 authorization flow, obtain an access token to access the
user's calendar data through the Microsoft Graph API. For more information,
see: Microsoft Identity Platform and OAuth 2.0 Authorization Code Flow and Get
access on behalf of user.
3. Perform integrated configuration on YMCS
1. Log in to YMCS.
2. Click System > Integration > Third-Party Service.
3. In the O365 module, click Edit.


                                                                                         47 / 108
  Yealink Management Cloud Service(YMCS) U...




4. Fill in the information you obtained in step 1 and click Save.




5. If the verification is successful, you can click Sync Now in the pop-up window to
  synchronize calendar resources immediately Account and calendar data, or you can click




                                                                                       48 / 108
  Yealink Management Cloud Service(YMCS) U...




  to enable this feature.

  💡    NOTE
       Calendar resource accounts are synchronized once every 24 hours, and
       calendar data is synchronized in real time.




Service Now
Step 1 Apply for Client ID and Client Secret information

Procedure
1. Search for System Oauth in ALL and select Application Registry to enter the application
  page.




                                                                                    49 / 108
  Yealink Management Cloud Service(YMCS) U...




2. Enter the page and click New to create the Client ID and Client Secret information provided
  to the YMCS platform for synchronizing data.




3. Select Create an OAuth API endpoint for external clients.




4. Create Client ID and Client Secret.
  Fill in the Name, Client ID, and Client Secret, then click Submit.




                                                                                      50 / 108
  Yealink Management Cloud Service(YMCS) U...




  💡   NOTE
      Remember the Client ID and Client Secret information here.


  💡   TIP
      Client Secret length should be 32 to 128 characters.

Step 2 Create Alarm Sync User

Procedure
1. Search User Administration in ALL and select Users to enter users management page.




2. Click New to create user information for the YMCS platform to synchronize data.


                                                                                     51 / 108
  Yealink Management Cloud Service(YMCS) U...




3. Fill in User ID, First name, Last name, and click Save to create a user.




  💡    NOTE
       The user created here will be the caller of the incident work order record.

4. Click Set Password > Generate > Save Password to set the password.




                                                                              52 / 108
Yealink Management Cloud Service(YMCS) U...




💡   NOTE
      After generation, you can click




                                              53 / 108
  Yealink Management Cloud Service(YMCS) U...




         to copy the currently generated password.
         After saving, you need to reset your password by default. Here you can
         choose to use the account login to change the account password, you can
         also choose to uncheck the Password need reset checkbox to update.

5. Add role.
  Click Edit on the Roles tab, search for incident_manager, click




                                                                          54 / 108
Yealink Management Cloud Service(YMCS) U...




> Save.




                                              55 / 108
  Yealink Management Cloud Service(YMCS) U...




6. Click Save.
Step 3 Configuration on YMCS

Procedure
1. Sign in YMCS.

2. Click System > Integration > Third-Party Service.

3. In the Servicenow module, click Edit.




                                                       56 / 108
  Yealink Management Cloud Service(YMCS) U...




4. Fill in Servicenow information.




5. Click Save.

6. Click




                                                57 / 108
  Yealink Management Cloud Service(YMCS) U...




  to enable this feature.




Step 4 Configure ServiceNow Callback

Introduction
After configuring the callback, ServiceNow Incident closure and cancellation
actions will be synchronized back to the alarm status through YMCS's OpenAPI.

Get OpenAPI Access Key
1. Sign in YMCS.
2. Click System > Integration > API.

                                                                         58 / 108
  Yealink Management Cloud Service(YMCS) U...




Configure Callback Scripts
1. Search Business Rules in All, and click the one in the System Definition to enter.




2. Click New.




                                                                                        59 / 108
  Yealink Management Cloud Service(YMCS) U...




3. Set the information.
  Name
  Table: Incident.
  Select Advanced.
  When to run:
    When: Select After.
    Filter Conditions: Set the State field to changes.




4. configure script.
Configure the callback script in the Advanced tab.




                                                         60 / 108
  Yealink Management Cloud Service(YMCS) U...




4. Click Submit.

  💡   NOTE
      The API address, accessKeyId, and accessKeySecret here need to
      configure the Access Key information of your YMCS enterprise account.




 (function executeRule(current, previous /*null when async*/ ) {


 // openapi address
 var endpoint = 'your openapi address';
 // Replace with your access key information

                                                                        61 / 108
    Yealink Management Cloud Service(YMCS) U...

accessKeyId='your access key id';
accessKeySecret='your access key secret';


changeYMCSAlarmStatus(endpoint, accessKeyId, accessKeySecret, current, previous);
})(current, previous);


function changeYMCSAlarmStatus(endpoint, accessKeyId, accessKeySecre, current,
previous){
// Only handles update status and the status is closed or cancelled
if (!(current && previous) || !(current.state == 7 || current.state == 8)) {
return;
}
// Check whether the configuration is configured
if(!isVaildConfiguration(endpoint, accessKeyId, accessKeySecret)){
return;
}
// No processing will be performed if the status has not changed.
if (current.state == previous.state) {
return;
}


var token = getTokenCache(endpoint, accessKeyId, accessKeySecret);
if(!token) {
return;
}
// Only handles closing and cancelling state sync
// Closed ==> Resolved
// Canceled ==> Ignored
if (current.state == 7) {
synchronousIncidentStatus(endpoint, token, current.correlation_id, 2);
} else if (current.state == 8) {
synchronousIncidentStatus(endpoint, token, current.correlation_id, 3);
}
}


                                                                                 62 / 108
    Yealink Management Cloud Service(YMCS) U...



// Check whether the configuration is configured
function isVaildConfiguration(endpoint, accessKeyId, accessKeySecret){
if(!endpoint ||!accessKeyId || !accessKeySecret
|| endpoint == '' ||accessKeyId == '' || accessKeySecret == ''){
return false;
}
return true;
}


// Synchronize the alarm status of YMCS platform
function synchronousIncidentStatus(endpoint, token, alarmId, status){
gs.info('[YMCS] synchronous incident status start');
if(!token || !alarmId || alarmId == '') {
return;
}
var alarmOpenApi= endpoint + '/v2/dm/alarm/changeStatus';
var authorization = token['token_type'] + ' ' + token['access_token'];
var headers = {
Authorization: authorization,
timestamp: new Date().getTime(),
nonce: getNonce()
};
var requestBody = {
ids: [alarmId + ''],
status: status + ''
};
var response = request('PATCH', alarmOpenApi, requestBody, headers);
if(!response) {
gs.warn('[YMCS] Synchronous incident status response is empty');
return;
}
var responseObject = JSON.parse(response);
if(isError(responseObject)) {


                                                                         63 / 108
    Yealink Management Cloud Service(YMCS) U...

gs.warn('[YMCS] Synchronous incident failure, response: ' + JSON.stringify(response));
} else {
gs.info('[YMCS] synchronous incident status end, responseObject: '+
JSON.stringify(response));
}
}


// Get authorization token
function getTokenCache(endpoint, accessKeyId, accessKeySecret){
var TOKEN_TYPE_KEY = 'YMCS_CACHE_TOKEN';
var ACCESS_TOKEN_KEY = 'YMCS_CACHE_ACCESS_TOKEN';
var EXPIRY_KEY = 'YMCS_CACHE_EXPIRY';
var tokenType = gs.getProperty(TOKEN_TYPE_KEY);
var accessToken = gs.getProperty(ACCESS_TOKEN_KEY);
var expiry = gs.getProperty(EXPIRY_KEY);
if (accessToken && expiry) {
var now = new Date().getTime();
if (expiry > now) {
return {
'token_type': tokenType,
'access_token': accessToken
};
}
}
// If there is no valid token, get a new one
var newToken = getToken(endpoint, accessKeyId, accessKeySecret);
if(isError(newToken)) {
gs.warn('[YMCS] Get token error:'+ JSON.stringify(newToken));
return undefined;
}
// Cache the new token to system properties as cache
gs.setProperty(TOKEN_TYPE_KEY, newToken['token_type']);
gs.setProperty(ACCESS_TOKEN_KEY, newToken['access_token']);
var expiryTimestamp = new Date().getTime() + (newToken['expires_in'] * 1000) - 10000;


                                                                                    64 / 108
    Yealink Management Cloud Service(YMCS) U...

gs.setProperty(EXPIRY_KEY, expiryTimestamp);
return newToken;
}


// Get authorization token
function getToken(endpoint, accessKeyId, accessKeySecret){
var tokenApi= endpoint + '/v2/token';
var requestBody = {
grant_type: 'client_credentials'
};
var headers = {
Authorization: getBasicAuth(accessKeyId, accessKeySecret),
timestamp: new Date().getTime(),
nonce: getNonce()
};
var response = request('POST', tokenApi, requestBody, headers);
if(!response) {
gs.warn('[YMCS] Get token response is empty');
return undefined;
}
var tokenObject = JSON.parse(response);
if (isError(tokenObject)) {
gs.warn('[YMCS] Failed to get token, response:' + JSON.stringify(tokenObject));
return undefined;
}
return tokenObject;
}


// clear token cache
function clearTokenCache(){
gs.setProperty('YMCS_CACHE_TOKEN', '');
gs.setProperty('YMCS_CACHE_ACCESS_TOKEN', '');
gs.setProperty('YMCS_CACHE_EXPIRY', '');
}


                                                                                  65 / 108
