App Auth Guide

How Do You Reuse an Existing App Connection in Custom Code?

Let the platform that owns the connection make the call, and keep tokens out of your code.

App AuthCustom CodeIntegrations

By Troy Tessalone · · 9 minutes

App Auth Guide

A practical field guide from Automation Ace.

Short answer: you reuse an existing app connection in custom code by letting the platform that owns the connection make the authenticated call. In Zapier use the app's API Request action and process the result in a Code step; in Make use the app's Make an API Call module; in n8n use the HTTP Request node with the app's predefined credential; in Pipedream workflows add the app as a prop and use its auth in your code step. For your own apps and services, store connections in a managed auth platform such as Nango or Pipedream Connect and call APIs with the connection ID. Avoid copying tokens out of a tool: they expire and leak access.

Short answer

  • Inside an automation: API request actions or modules reuse the connection; code handles the logic.
  • Code with auth inside a workflow: Pipedream code steps, or n8n predefined credentials.
  • Your own backend: a managed auth connection ID plus a proxy.
  • Never: paste a copied access token into code.

Why reuse a connection instead of creating a new one

  • Users already approved access; asking again adds friction.
  • One connection means one place to reconnect, rotate, or revoke.
  • Built-in refresh keeps tokens valid; a copied token stops working when it expires.
  • Ownership is clear: the connection belongs to a person or a service account you can see. See labeling Zapier app connections.

Options by platform

Where the connection livesHow to use it from custom codeWatch out for
ZapierThe app's API Request action (where offered) calls any endpoint with your connected account; send results to a Code step or the next stepCode by Zapier steps cannot read app connections directly
MakeThe app's Make an API Call module uses the module's connection; pass its output to later modulesEach call counts as an operation
n8nThe HTTP Request node with a predefined credential type for that appCredentials are not exposed to Code nodes by design
Pipedream workflowsAdd the app as a prop in a code step and read the auth it provides (for example an OAuth access token) in your codeYou are handling a live token; never log it
Managed auth platformCall the proxy or SDK with the connection IDStore IDs per user; keep the secret key server-side
Zapier MCPCall enabled actions from code through an MCP clientActions only, not arbitrary endpoints

Zapier: API Request plus a Code step

Zap: New row in Google Sheets
  1. HubSpot > API Request (uses your HubSpot connection)
       Method: GET
       URL:    https://api.hubapi.com/crm/v3/objects/companies/search
       Body:   {"filterGroups":[{"filters":[{"propertyName":"domain",
                "operator":"EQ","value":"{{domain}}"}]}]}
  2. Code by Zapier (JavaScript): reshape the response, compute a score
       const results = JSON.parse(inputData.body).results || [];
       return { companyId: results[0]?.id || null, matches: results.length };
  3. Next steps use companyId and matches

The API Request action is pre-wired to the app's base URL and connection; see using the API Request action in Zapier app integrations and API by Zapier vs Webhooks by Zapier. If a connection expires, see why a Zapier app connection expires.

Make and n8n

  • Make: many apps include a Make an API Call module that uses the same connection as the app's other modules. Enter the path relative to the app's API, and Make adds the auth. For apps without one, see calling any API with the Make HTTP module.
  • n8n: in the HTTP Request node, choose Predefined Credential Type and pick the app's credential, so n8n adds the auth to your custom request. Use Code nodes for the logic before or after.

Pipedream: app props in code steps

// Pipedream workflow code step (Node.js): reuse the connected Slack account
export default defineComponent({
  props: {
    slack: { type: "app", app: "slack" },   // pick the connected account in the UI
  },
  async run({ steps, $ }) {
    const res = await fetch("https://slack.com/api/conversations.list?limit=50", {
      headers: { Authorization: `Bearer ${this.slack.$auth.oauth_access_token}` },
    });
    const data = await res.json();
    return data.channels.map(c => ({ id: c.id, name: c.name }));
  },
});

Pipedream lets code steps declare an app prop, choose a connected account in the UI, and use the auth it provides. This is the most flexible option inside a workflow, and the token is live in your code, so treat it with care.

Your own code: managed auth connections

When the code runs in your own app, Worker, or service, the “existing connection” should be a managed auth connection that you can reference by ID:

// Your own backend with a managed auth platform (Nango shown)
const res = await fetch("https://api.nango.dev/proxy/v3/users", {
  headers: {
    Authorization: `Bearer ${process.env.NANGO_SECRET_KEY}`,
    "Provider-Config-Key": "greenhouse",
    "Connection-Id": org.greenhouseConnectionId,   // the "existing connection"
  },
});

Full walkthroughs: calling APIs from JavaScript without managing OAuth tokens and managed app auth in a Cloudflare Worker.

Which option to choose

SituationBest option
Logic fits inside an automation, and the app has an API request action or moduleUse it, and keep custom code for data shaping
You need real code with the app's auth inside a workflowPipedream code steps, or n8n HTTP Request with predefined credentials
Your own app or service needs the connectionA managed auth platform (connection ID + proxy)
An AI assistant needs the connectionZapier MCP, or agent tools from a managed auth platform
You are tempted to copy a token out of a toolDon't; it will expire and it leaks access

Want an AI agent to reuse the connections instead? See reusing automation app connections in an AI agent.

Security and ownership

  • Use a connection whose account has only the access the job needs, ideally a service account for shared workflows.
  • Never print, log, or return tokens from code steps.
  • Document which workflows and services rely on each connection, so reconnecting or offboarding does not break them; see what happens to automations when someone leaves.
  • Prefer the platform making the call (API request actions, proxies) over code that handles the token.

Frequently asked questions

Can I use a Zapier app connection in a Code by Zapier step?

Not directly. Use the app’s API Request action, which calls the app’s API with your connected account, and pass its output to a Code step for processing.

How do I reuse a Make connection to call an API endpoint?

Use the app’s Make an API Call module, which uses the same connection as the app’s other modules. Enter the endpoint path, and Make adds the authentication.

How do I reuse an n8n credential in a custom HTTP request?

In the HTTP Request node, choose Predefined Credential Type and select the app’s credential. n8n adds the authentication to your request.

How do I use a connected account in Pipedream code?

Declare the app as a prop in your code step, select the connected account in the workflow UI, and use the auth it provides, such as the OAuth access token, in your request. Never log the token.

Should I copy an access token from an automation tool into my code?

No. Access tokens expire and refresh, so a copied token soon stops working, and it leaks access if exposed. Let the platform make the call or use a managed auth connection ID.

App AuthCustom CodeIntegrations

Disclaimer: Managed app auth platforms, their SDKs, endpoints, plans, and features change quickly; details reflect public documentation and coverage at the time of writing, so confirm current details with each provider before building. Automation Ace is not affiliated with Composio, Nango, Pipedream, Arcade, or the other companies named here unless a link is marked as an affiliate link. This article may include links to apps, products, or services; some links may be affiliate links, which means Automation Ace may earn a commission at no extra cost to you.

Build Better Systems

Ready to automate with confidence?

Share your tools, process, and goals. Automation Ace can design the Zapier, AI, and automation setup that fits your business.

Start a Project →