---
url: /process-functions/script-getoauth.md
description: >-
  Returns a stringified value of tokens to connect with the specified
  integration.
---

# script.getOAuth

Returns a stringified value of tokens to connect with the specified integration.

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

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

```js
const data = JSON.parse(script.getOAuth(key));
```

#### Parameters

* `key` - Must match the name of the integration you created.

#### Example

```js
const data = JSON.parse(script.getOAuth(key))
```

:::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.
:::

Example response from Xero integration. (Tokens have been removed in the example below)

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

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