Authentication
We need to send a request to the Authentication endpoint to get the token.
⚠️ You can find the needed blocks from the "transformer" in the FME tools.
To make an HTTP request:
- Select a
Creatorblock (There is no need to change anything in its settings). - Select an
HTTPCallerand connect the Creator output arrow to the HTTPCaller input.
- Click on the settings of
HTTPCaller. - Fulfill the
Request URLinput: 🔗 https://account.tes.ca/connect/token - Set
HTTP MethodtoPOST
- Set the
Content TypetoJSON(application/json). ⚠️ Since we know that the response would be a JSON document. - Click on the down arrow next to the
Upload Datainput, and then from the dropdown menu, chooseOpen Text Editor.
- Put the following object:
{
"username":"INTEGRATION_USERNAME",
"password": "INTEGRATION_PASSWORD",
"client_secret": "INTEGRATION_SECRET",
"client_id": "integration",
"grant_type": "password",
"scope": "integration"
}
- Set
Save Response Body ToAttribute
After the setup of the HTTPCaller, we have to save the token and the response message. To extract these JSON properties from the JSON document we got, we need to select a JSONExtractor block and connect the output of the HTTPCaller to the input of the JSONExtractor.
JSONExtractor Settings:
- Set the
Input SourcetoJSON Document. - Click on the down arrow icon next to the Input Source. From the dropdown menu, choose
Attribute Valueand then select_response_bodywhich is actually the response body of the HTTPCaller saved in_response_bodyattribute. - Now, we have to extract the JSON properties we want to save in the attributes.
- In the
Target Attributecolumn, kwrite thetokenand its correspondingJSON Queryvalue which isjson[“access_token”]. - click on Ok!
⚠️ We are saving the token to use in further requests.
⚠️ We are saving the responseCode to check whether we had any error or not.