ESRI ArcGIS Online Token Request

This can be used with your ESRI ArcGIS account in order to request a token from your Forms inMotion server that can be used with your forms for routing and mapping functionality.  

Forms InMotion Version Requirement

This functionality requires Forms InMotion version 2.6.11 or greater.

ESRI now requires TLS 1.2 to work. If FiM cannot update ESRI token verify the server is using tls1.2.


Use of this integration with ArcGIS may result in charges to your ArcGIS account.  Please make sure you understand what you're doing when you publish forms that utilize this integration.


Creating an application in ArcGIS Online

These instructions and screenshots were taken from the ArcGIS for Developers site on 1/3/2017. Specific instructions may have changed.

Sign in to your account at https://developers.arcgis.com.

Select Applications from the menu.

Click the Register New Application button.

Fill in the New Application Details with information about your specific implementation. This is only visible inside ArcGIS.

Once you have registered the application, the next screen will display a Client ID, Client Secret and a Token you can use for short-term testing.

The short-term token can replace YOUR_ESRI_TOKEN in the code sample below for debugging your code outside of your Forms InMotion application.

Using your ArcGIS application in Forms InMotion

Log in to your Forms InMotion application as a sysadmin. Click Administration, then Server Config. Enter your application Client ID and Client Secret that you generated in the previous step.

Calling the Token from your form

This integration utilizes the Forms_inMotion API call from your custom javascript.  You'll need to add a call to the Forms_inMotion function in your javascript and specify a call back for it.  An example of this is shown below:

Forms_inMotion API ESRI request
function runEsriQuery() {
	if (typeof Forms_InMotion === 'undefined') { 
    	esriToken = "YOUR_ESRI_TOKEN"; //specify a fallback token for testing outside of your Forms InMotion application
    	console.log('Esri token fallback used');
	} else {
    	Forms_inMotion("esritoken", "esricallback");
	}
}
function esricallback(data) {
	data = JSON.parse(data);
	if (data.OK) {
		document.getElementById('esridata').value = data.responseString;
	}
	else if (data.responseContent && data.responseContent=="UPDATING") {
		//the server had to generate a new token.  try this call again
		runEsriQuery();
	}
}

In the above example, the esritoken request is made and we check the response JSON.  If we get data.OK in the response object, then responseString contains the ESRI token.  If we got data.OK=false, then check the data.responseContent.  If the token has expired on the server, the server tells the client that the token expired and it immediately fetches a new one.  It is OK for the client to make the call again and the server should have received an updated token from ArcGIS.