Get Access Token
Customers will now get an opportunity to access the Field Service REST API, Fusion REST API or External API from their custom plugin via JWT Access Token. The plugin configuration screen has been extended with the new ‘Applications’ section that allows to choose the available application. Once it’s configured, the Mobile Plugin Framework sends all configured applications to the plugin on ‘init’ stage. The new “getAccessToken” procedure returns the JWT access token that is used for authorization of direct API calls.
Companies have an opportunity to access the Field Service REST API, Fusion REST API or External API from their custom plugin via JWT Access Token. The “getAccessToken” procedure returns the JWT access token that is used for authorization of direct API calls. The procedure is listed in the "allowedProcedure" collection that is sent in the "open"/"wakeup” method and says that the procedure is available.
{
"apiVersion": 1,
"method": "open"/"wakeup",
"entity": "...",
...
"buttonId": "...",
"openParams": {},
"allowedProcedures": {
...
"getAccessToken": true
}
}
On init stage, OFS returns the data of the configured Application for the particular Plugin in the "init" method.
The "resourceUrl" field is populated with the URL of the resource server. In case of Field Service API application, it is populated with the URL of the Plugin in order to use it in direct REST API requests. In the case of OAuth User Assertion or OAuth Client Credentials application, it is retuned the same as it is configured on the Modify Application screen.
init method
{
"apiVersion": 1,
"method": "init",
"attributeDescription": {},
"buttons": [],
"applications": {
"ofs_rest_api": {
"type": "ofs",
"resourceUrl": "https:// plugins-0-ofsc-xxxx.test.fs.ocs.oc-test.example.com",
},
"fusion_rest_api": {
"type": “oath_user_assertion",
"resourceUrl": "https://fa-xxxx-pintlabfadev.fa.ocs.oc-test.example.com"
},
"external_rest_api": {
"type": "oauth_client_credentials"
"resourceUrl": "https://external-rest-api-url.example.com"
}
}
}
init method with application that is not configured on Plugin Edit screen
{
"empty": {
"type": "unknown",
"resourceUrl": ""
}
}
}
callProcedure method
{
"apiVersion": 1,
"method": "callProcedure",
"callId": "1111111111",
"procedure": "getAccessToken",
"params": {
"applicationKey": "ofs_rest_api"
}
}
callProcedureResult method - success case
{
"apiVersion": 1,
"method": "callProcedureResult",
"callId": "1111111111",
"resultData": {
"token": "...",
"status": "success",
"detail": ""
}
}
callProcedureResult method - fail case
{
"apiVersion": 1,
"method": "error",
"errors": [
{
"type": "TYPE_PROCEDURE_PARAM",
"code": "CODE_PROCEDURE_PARAM_VALUE_INVALID",
"procedure": "getAccessToken",
"paramName": "applicationKey"
}
],
"callId": "1111111111"
}
{
"apiVersion": 1,
"method": "error",
"errors": [
{
"type": "TYPE_PROCEDURE_GET_ACCESS_TOKEN_ERROR",
"code": "CODE_GET_ACCESS_TOKEN_APPLICATION_NOT_CONFIGURED",
"procedure": "getAccessToken",
"data": {
"status": "unexpected_response",
"detail": "",
"token": ""
}
}
],
"callId": "1111111111"
}