script.getOAuth
Returns a stringified value of tokens to connect with the specified integration.
Follow the Creating an integration guide for more detailed information.
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))
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
}
Important
Token refreshing is usually done automatically by this function, there can be instances where you manually need to reauthorize the integration.