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.


This screenshot shows the Show Init Data section.

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.
    This screenshot shows the Procedures section.

Retrieving the Token

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


This screenshot shows the Token Retrieve process

Validate the Token by Fetching Data

With the access token obtained, you can now fetch data from a REST API to verify its validity.

Note: When making requests to the Oracle Fusion Field Service API, the Sample Plugin supports calls not only to the base Oracle Fusion Field Service domain but also to domains prefixed with plugins-0- or plugins-1-. This allows for flexibility in accessing different environments or instances.
fetch("https://field-service-instance.com/rest/api", {
 headers: {
 Authorization: "Bearer <accessToken>"
 }
})
.then(resp => resp.json())
.then(json => console.log(json));