By default, the DataSync Agent uses Basic Authentication to make API calls to your instance. However, you can also have the Agent use ServiceNow's OAuth 2.0 implementation to make the API calls.
With the OAuth 2.0 implementation, the Agent will initially use your credentials configured in the Agent's configuration file (agent.xml) to request an access token from your ServiceNow instance it will then use for accessing the table schema API. If the access token expires, it will use the refresh token to request a new access token. If the refresh token is expired, it will start the process all over again, using your credentials configured to request a new access token.
NOTE: The Agent will call to ServiceNow to get the schema for a ServiceNow table the first time it receives a record to insert into the database for that particular table. The Agent won't get the schema again for the table until there's a column change that requires it to get the schema from ServiceNow to understand what the column change should be.
Furthermore, if the Agent is restarted and has the <use_cache/> configuration directive and already has the schema for a table (schemas are stored locally in the Agent's bin/<instance>.service-now.com.schemas_directory folder), it won't get the schema until a column change.
Prerequisites
- Configure your ServiceNow instance as an OAuth API endpoint for external clients. You can also see here and here for additional details on setting this up in your ServiceNow instance.
- Create a ServiceNow user. This user must have the perspectium role in order to access the table schemas through the ServiceNow APIs. You can specify the user to have the Web service access only option selected if this user should only be used for the integration and not be able to login to your ServiceNow instance.
To configure the Agent to use ServiceNow's OAuth implementation, add the following attributes to your <instance_connection> configuration directive underneath <task> within your agent.xml file:
All attributes are required for the Agent to access your ServiceNow instance using OAuth.
Directive | Required attributes | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<instance_connection> |
NOTE: Since the DataSync Agent's configuration file (agent.xml) is XML-based, if you are using any special characters in the above values, you will need to escape them or else the agent.xml will not be readable by the Agent. For example, if your password has an & in the value, you will need to enter it as & in the agent.xml configuration. You can use a formatter to ensure the XML is escaped properly. For more information, contact Perspectium Support. <config> <agent> <subscribe> <task> ... <instance_connection auth_type="servicenowoauth" client_id="abcabcabcabc" client_secret="def456^)" password="password123" user="user1">https://instance.service-now.com</instance_connection> </task> </subscribe> </agent> </config> | ServiceNow instance URL |