MESA Docs
MESA Homepage
  • Welcome to MESA
    • Installing MESA
    • Dashboard
    • Core Concepts
    • Getting Help
  • Templates
    • Template Library
    • Installing & Editing
  • Workflow Builder
    • Triggers
    • Actions
    • Fields
      • Variables
      • Formatting Variables
      • Liquid Templating
    • Testing
  • Workflow Activity
    • Tasks
      • Troubleshooting
      • Replay
    • Logs
    • Time Travel
  • Best Practices
    • Set Titles & Descriptions
    • Track Time Saved
    • Enable Failure Notifications
    • Avoid Infinite Loops
  • Going Further
    • Plans & Billing
    • Notifications
    • Credentials
    • Understanding the Queue
    • Export & Import Workflows
    • Platform Thresholds & Limits
  • Built-in Tools
    • Activity Log
    • AI
    • API
    • Approval
    • MCP
    • Custom Code
      • Libraries
        • MESA SDK
        • Filter
        • Loop
        • Transform
        • oAuth
        • Shopify
        • ShopifyGraphql
      • FAQ
    • Data
    • Delay
    • Email
    • Filter
    • Form
      • Configure
      • Going Further
      • Technical Notes
    • FTP
    • Image
    • Loop
    • Package Tracking
    • Paths
    • Schedule
    • Scraper
    • SMS
    • Transform
    • Virtual Output
    • Weather
    • Web Request
    • Webhook
  • Apps
    • Airtable
    • Amazon S3
    • Asana
    • Blog Studio
    • ChannelApe
    • Claude
    • ChatGPT
    • Dall-E 2
    • Delighted
    • Digital Humani
    • Discord
    • DocuSign
    • Dropbox
    • Etsy
    • Facebook
    • Fera.ai
    • Gatsby
    • Gmail
      • Send Email
    • Google Analytics 4
    • Google Analytics UA
    • Google Calendar
    • Google Drive
    • Google Forms
    • Google Sheets
      • Add Row
      • Query Rows
      • Update Row
      • Row Created
      • Row Updated (Advanced)
      • Creating New Spreadsheets
      • Technical Notes
    • Gorgias
    • Govalo
    • Help Scout
    • Hubspot
    • Infinite Options
    • Intercom
    • IPDetective
    • Judge.me
    • Katana
    • Klaviyo
      • API Deprecation
    • Loop Returns
    • Loyalty Lion
    • Mailchimp
    • Mailgun
    • Mandrill
    • Mantle
    • Notion
    • Odoo
    • Omnisend
    • Page Studio
    • Pinterest
    • Printful
    • PrintNode
    • QuickBooks
    • Rebuy
    • Recharge
    • Remove.bg
    • Returnly
    • Rivo
    • Salesforce
    • Segment
    • Sendlane
    • Shippo
    • ShipStation
    • Shopify
      • Technical Notes
        • Configuring Your Payload
        • Modifying and Filtering Get Lists
        • Parameters
        • Error Codes
        • Accuracy of orders_count Variable
        • Accuracy of Count Products Action
        • Using the Gift Cards API
        • How to Find a Specific Record in the Testing Interface
        • Order, Customer, and Product Updated Trigger Frequency
    • Shopify Flow
    • Shopify Plus
    • Shopify Retail POS
    • Skio Subscriptions
    • Slack
    • Smartrr
    • Smile.io
    • Square
      • Updating Inventory
      • Frequently Asked Questions
    • Stamped.io
    • Stripe
    • Thanks.io
    • TikTok
    • Tracktor
    • Twilio
    • Uploadery
    • Wonderment
    • Xero
    • Yotpo
    • Yotpo Loyalty
  • For developers
    • Admin API
    • Command Line Interface
    • Embedding templates
  • Frequently asked questions
    • Why isn't the log search returning logs with the search I entered?
    • Is it possible to handle errors or retry steps?
    • How do I handle a failed task?
    • Does MESA auto-save workflows?
    • Can I Use Apps That Don't Have a MESA Connector?
    • Why is my workflow action adding the same data each time it occurs?
    • How do I cancel automations that are already in progress?
    • How do I cancel my MESA subscription or 7-day trial?
    • Can you import code from npm in custom code?
    • Do you have a Slack Community?
Powered by GitBook
On this page
  • new Oauth(grantType, tokenKey)
  • constructor(grantType, tokenKey, hasHeaders)
  • init()
  • request(method, path, data, options)
  • get(path[, options])
  • post(path, data[, options])
  • put(path, data[, options])
  • patch(path, data[, options])
  • delete(path[, options])

Was this helpful?

  1. Built-in Tools
  2. Custom Code
  3. Libraries

oAuth

vendor/Oauth.js

new Oauth(grantType, tokenKey)

Class containing methods to authenticate and make authenticated requests with a third party API

Parameters

Name
Type
Description

grantType

string

Oauth grant type. One of: refresh_token, password, or custom.

tokenKey

string

The key of the secret containing the oAuth token information.

Examples

// Refresh token flow.
const Oauth = require('vendor/Oauth.js');
const oauth = new Oauth('refresh_token', 'service.oauth');
// Username password flow.
const Oauth = require('vendor/Oauth.js');
// Save username and password from external standalone secrets.
let token = JSON.decode(Mesa.secret.get('service.oauth', '{}'));
token.username = Mesa.secret.get('service-username');
token.password = Mesa.secret.get('service-password');
Mesa.secret.set('service.oauth', JSON.stringify(token));
const oauth = new Oauth('password', 'service.oauth');
// Skubana flow (access_token that does not expire)
const Oauth = require('vendor/Oauth.js');
const oauth = new Oauth('custom', 'skubana.oauth');
const getResponse = oauth.get('https://dev.skubana.com/v1/orders');
Mesa.log.info('Get Response: ', getResponse);
// Oauth Usage
const getResponse = oauth.get('https://example.com/products.json');
const postResponse = oauth.post('https://example.com/products.json', {});
Mesa.log.info('Get Response: ', getResponse);
Mesa.log.info('Post Response: ', postResponse);

Returns

  • Void

constructor(grantType, tokenKey, hasHeaders)

Parameters

Name
Type
Description

grantType

string

tokenKey

string

hasHeaders

boolean

Returns

  • Void

init()

Init the access token

Returns

  • Void

request(method, path, data, options)

Request method with the refresh token retry if fails.

Parameters

Name
Type
Description

method

string

Request method.

path

string

Request path.

data

object

options

Types.RequestOptions

Additional configuration for Oauth calls

Returns

  • object

get(path[, options])

Make a GET request to an external Rest API

Parameters

Name
Type
Description

path

string

Request path

options

Types.RequestOptions

Additional configuration for Oauth calls

Optional

Returns

  • object

post(path, data[, options])

Make a POST request to an external Rest API.

Parameters

Name
Type
Description

path

string

Request path

data

object

Request payload

options

Types.RequestOptions

Additional configuration for Oauth calls

Optional

Returns

  • object

put(path, data[, options])

Make a PUT request to an external Rest API.

Parameters

Name
Type
Description

path

string

Request path

data

object

Request payload

options

Types.RequestOptions

Additional configuration for Oauth calls

Optional

Returns

  • object

patch(path, data[, options])

Make a PATCH request to an external Rest API.

Parameters

Name
Type
Description

path

string

Request path

data

object

Request payload

options

Types.RequestOptions

Additional configuration for Oauth calls

Optional

Returns

  • object

delete(path[, options])

Make a DELETE request to an external Rest API.

Parameters

Name
Type
Description

path

string

Request path

options

Types.RequestOptions

Additional configuration for Oauth calls

Optional

Returns

  • object

PreviousTransformNextShopify

Last updated 6 months ago

Was this helpful?