# Authentication

The authentication properties specify the details that must be used to authenticate a user against a specific Xero application.

#### Prerequisites: <a href="#prerequisites" id="prerequisites"></a>

* You have registered an account on [Xero](https://www.xero.com/za/signup/api/).
* You have created an App on Xero's [applications portal](https://developer.xero.com/).

**Important:**

* For apps created after December 2019, *OAuth2* is used for authentication.
* For apps created before December 2019, *OAuth1* was used for authentication.

***

### Connecting to Xero apps using OAuth2 <a href="#connecting-to-xero-apps-using-oauth2" id="connecting-to-xero-apps-using-oauth2"></a>

In Linx, for any function that connects to a Xero app that uses OAuth2, provide your Xero app's authentication details in the function's Authentication properties:

<div align="left"><figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-cd178663859b07a63ff895d90743edd631a1cf04%2Fauthtype.png?alt=media" alt=""><figcaption><p>Authentication Type for OAuth2</p></figcaption></figure></div>

* *Type*: Select 'OAuth2' from the drop-down.
* *OAuth2 authentication*: Create the following values on this [Xero Token Generator](https://xerotokengenerator.z16.web.core.windows.net/):

  * *TenantId*: Tenants are the organisations (small businesses) or practices (accounting firms) to which a user belongs and which they can access. The TenantID will be provided by Xero when setting up your App.
  * *RefreshToken*: The token that is used to refresh the access token once it has expired. Provided by Xero during the authentication step.
  * *Note:* For the Xero Token Generator to create your Refresh Token, your Xero app's OAuth2 redirect URI must be <https://xerotokengenerator.z16.web.core.windows.net/>.

  Get these values from the Xero portal, created when you registered your Xero app:

  * *ClientId*: Your unique client identifier. From your App on Xero.
  * *ClientSecret*: The secret credentials that will be used to authenticate your connection. From your App on Xero.

***

### Connecting to Xero apps using OAuth1 <a href="#connecting-to-xero-apps-using-oauth1" id="connecting-to-xero-apps-using-oauth1"></a>

*Note: This section is only relevant to Xero apps created before December 2019. Xero apps using OAuth1 are expected to work until the end of 2020.*

Get these from the Xero portal, created when you registered your Xero app:

* CertificatePath
* CertificatePassword
* ConsumerKey
* ConsumerSecret

While setting up the private application, make sure you save the following elements, as you will need them to set the authentication values:

* Public certificate file in PFX format.
* The password to the public certificate.
* ConsumerKey provided by the Xero API configuration.
* ConsumerSecret provided by the Xero API configuration.

#### Authentication properties <a href="#authentication-properties" id="authentication-properties"></a>

<div align="left"><figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-cd178663859b07a63ff895d90743edd631a1cf04%2Fauthtype.png?alt=media" alt=""><figcaption><p>Authentication Properties Type</p></figcaption></figure></div>

* *Type*:

Select 'OAuth1' from the drop-down.

* *Authentication*:

  <figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-6a0f55a6843fdbf025358bfd83a58d31502ea96a%2Fauthenticationparametervalues.png?alt=media" alt=""><figcaption><p>Authentication Parameter Values</p></figcaption></figure>

  * *CertificatePath*: the path to the public certificate in PFX format on your hard drive.
  * *CertificatePassword*: the password to the public certificate provided in CertificatePath.
  * *ConsumerKey*: Consumer Key credentials for your private application provided by Xero.
  * *ConsumerSecret*: Consumer Secret credentials for your private application provided by Xero.

<div align="left"><figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-9b294f60ebeaef30041e113d86f972d40ead1959%2Fappcredentials.png?alt=media" alt=""><figcaption><p>Application Credentials</p></figcaption></figure></div>

***

### Links <a href="#links" id="links"></a>

[Xero documentation on OAuth / OAuth2 changes](https://developer.xero.com/documentation/oauth2/overview)

[Xero documentation on OAuth / OAuth2 flows](https://developer.xero.com/documentation/oauth2/auth-flow)
