Skip to main content

Axios with Oauth 1.0a

Axios makes it easy to send asynchronous HTTP requests to REST endpoints and perform CRUD operations. This integration supports Oauth 1.0a

Network Connection needs

This integration needs network access to the server where the service is running.

See the Network access page for details about how to achieve that.

Credential configuration

First, you need the baseURL of the API you're calling. In the JSON field you can add HTTP headers you want to be sent in all requests.

For the Oauth params:

  • You need to provide the consumer key and consumer secret.
  • Optionally you can provide the token and token secret.
  • In the JSON field you can add any of the params you can see here.

Here you have an example of a filled credential configuration form in YepCode:

Axios snippets available in editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const axiosClient = yepcode.integration.axiosOauth10a('credential-slug')
New integration from plain authentication data
const axios = require("axios");
const { default: addOAuthInterceptor } = require("axios-oauth-1.0a");

const axiosClient = axios.create({
baseURL: 'https://some-domain.com/api/',
headers: {'X-Custom-Header': 'foobar'}
});

const options = {
key: "your-oauth-consumer-key",
secret: "your-oauth-consumer-secret",
token: "your-oauth-token",
tokenSecret: "your-oauth-token-secret",
verifier: "your-oauth-verifier"
};
addOAuthInterceptor(axiosClient, options);
tip

After your have created this client you can use any of the Axios snippets.