script.getOAuth
Returns the tokens to connect to an integration.
Follow the 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
stringThe tokens, as a JSON string.
Important
Must be wrapped inside JSON.parse to get access to properties inside.
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
js
const data = JSON.parse(script.getOAuth("Xero"));json
{
"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.
Important
Token refreshing is usually done automatically by this function, there can be instances where you manually need to reauthorize the integration.