Sample Plugin to Obtain Access Token
This topic outlines the typical flow when using the Sample Plugin to obtain an access token and subsequently fetch data from a REST API. This sample plugin example facilitates end-users' successful connection to and retrieval of data from REST APIs.
Initial Application List
Upon initialization, the plugin receives a message containing a list of available applications. This message includes the resourceUrl field for each application.
The resourceUrl is directly obtained from the plugin's configuration and is used by the Sample Plugin in its subsequent API requests.
The following screenshot provides details of the Initialization data, demonstrating how the plugin receives and utilizes the resourceUrlfield from the configuration during its initialization process.

Obtaining an Access Token
To acquire an access token using the Sample Plugin, you use the Procedures functionality as shown in the screenshot below. You can
- Send a callProcedure method call to the plugin.
- Specify getAccessToken as the desired procedure within the callProcedure
call.
Retrieving the Token
Once the callProcedure with getAccessToken is processed, the resulting access token is available in the callProcedureResult response method as shown below:

Validate the Token by Fetching Data
With the access token obtained, you can now fetch data from a REST API to verify its validity.
fetch("https://field-service-instance.com/rest/api", {
headers: {
Authorization: "Bearer <accessToken>"
}
})
.then(resp => resp.json())
.then(json => console.log(json));