Skip to main content

API keys and access tokens

API keys and access tokens are crucial for secure communication with APIs. API keys identify applications, and access tokens authenticate and validate requests, ensuring secure data exchange between applications and APIs

Add API key authorization

To add an API key:

  1. Go to Studio > API > click the particluar API > Headers > + Add Headers.

  2. In Key enter Authorization and in Value enter the API key. Click Add.

    drawing
  3. Click Send to test the API, if you recieve a 200 response the API has been authorized and works successfully.

    drawing
  4. Build a flow for your use case and include the API node wherever you want the flow to hit the API. Fetch this API in the node and build the rest of the flow.

Pass dynamic access tokens

To fetch a dynamic access token:

  1. Add the API. In Key enter Authorization and in Value enter the variable name in {{{}}} format, for example {{{auth_token}}}.

  2. Go to Functions and create a new function that filters out the access token from the response.

Sample code:

let { apiResponse } = ymLib.args; // retrieve API response
let token = JSON.parse(apiResponse.body);

console.log(token);

return token.token_type + " " + token.access_token;
  1. Build a flow for your use case and include the API node wherever you want the flow to hit the API.

  2. Store the response of that API node in a variable.

  3. Scroll down to Parse using function and add the following:

  • Select variable: Create/choose the variable in which you want to store the parsed response. Here the variable would be auth_token.
  • Add function: Choose the function created in step
  1. Include another API node and add/or fetch the API (created in step 1). In the Dynamic variable, fetch the auth_token variable (created in step 5).

    drawing

By this way you can authenticate the API and use the dynamic access token throughout the flow to authenticate different APIs from the same server.