Help Center
< All Topics
Print

Overview

This script refreshes tokens which were originally obtained to establish a connection to the Xero package. Without the token refresh, any tokens would expire within 30 minutes after the time they were issued. By having a refresh process, other Azure runbooks can connect to Xero even if those scripts only run once per month.

Where to Find It

Name of runbook: Speakeasy-XeroAccessTokens
All Azure runbook scripts can be viewed via the following link: Azure RunBooks Home, then selecting the appropriate runbook name. The script is hosted in the cloud, using Microsoft Azure, because it is run on a scheduled basis.  See the following document (advanced users only!!) regarding how the script was initially created in the Azure environment: Creating a PowerShell script in Azure
This script is scheduled to run using a schedule – having selected the relevant script, click the see the “Schedules” link on the left hand side of the view. The script generates a log file which can be checked for errors.

How it Works

The purpose of this script is to refresh a token (an “access token”) which provides programmatic access to data in the Xero finance package.  It achieves this by retrieving the current refresh token from the SpeakeasyXeroRefreshToken Azure Automation variable and making a call to Xero for a token refresh. If successful, Xero will respond with a new access token and refresh token. These new values are stored in their respective Azure Automation variables. If the token is not refreshed within 30 minutes, access to Xero data is prohibited – hence the reason the refresh takes place every twenty minutes. If this occurs, the SpeakeasyGetXeroTokens.ps1 script needs to be re-executed.
See the Obtaining Xero Access and Refresh Tokens page, which describes the Xero authentication process in more detail, including how the initial access and refresh token is obtained.