---
url: /process-functions/script-getoauth.md
description: Returns the tokens for an integration.
---

# script.getOAuth

Returns the tokens to connect to an integration.

Follow the [Creating an integration](/technical/creating-an-integration) guide for more detailed information.

```js
script.getOAuth(key)
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `key` | `string` | The name of the integration you created. |

## Returns

The tokens, as a JSON string.

::: danger Important
Must be wrapped inside `JSON.parse` to get access to properties inside.
:::

::: tip Note
Note that the response here will vary depending on the response from the platform you're integrating in, be sure to check what keys exist in the response.
:::

## Examples

::: code-group

```js [oauth.js]
const data = JSON.parse(script.getOAuth("Xero"));
```

```json [Xero response]
{
    "id_token": "...",
    "access_token": "...",
    "expires_in": 1800,
    "token_type": "Bearer",
    "refresh_token": "...",
    "scope": "openid profile email accounting.transactions",
    "renewed": false
}
```

:::

Tokens have been removed from the example response.

::: danger Important
Token refreshing is usually done automatically by this function, there can be instances where you manually need to reauthorize the integration.
:::
