Sample Plugin to Obtain Access Token

This topic describes how a plugin, such as the Sample Plugin, can use the configured Oracle Fusion Field Service application to obtain an access token using the getAccessToken procedure.

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 obtained from the plugin's configuration and is used by the Sample Plugin in subsequent API requests.

The following screenshot illustrates the Initialization data, showcasing how the plugin obtains and employs the resourceUrl field from its configuration during the initialization process.


This screenshot shows the Sample Plugin initilization data section.

Obtain an Access Token

To acquire an access token using the Sample Plugin, you need to utilize the Procedures functionality as shown in the screenshot below. You can

  • Send a callProcedure method call to the plugin.
  • Within the callProcedure call, specify getAccessToken as the desired procedure.

This screenshot shows the procedure section.

Retrieve the Token

Once the callProcedure with getAccessToken is processed, the resulting access token will be available in the callProcedureResult response method as shown below:


This screenshot shows the Request response method

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://fusion-instance.com/hcmRestApi/resources/latest/workers", {
    headers: {
        Authorization: "Bearer <accessToken>"
    }
})
.then(resp => resp.json())
.then(json => console.log(json));