Sample code for 30+ languages & platforms
React Native

Magento Request with OAuth1.0a Authentication

See more Magento Examples

Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)

Chilkat React Native Downloads

React Native
import { Http, JsonObject } from '@chilkat/react-native'

async function chilkatExample() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const http = new Http();

  http.oAuth1 = true;
  http.oAuthVerifier = '';
  http.oAuthConsumerKey = 'MAGENTO_CONSUMER_KEY';
  http.oAuthConsumerSecret = 'MAGENTO_CONSUMER_SECRET';
  http.oAuthToken = 'MAGENTO__TOKEN';
  http.oAuthTokenSecret = 'MAGENTO_TOKEN_SECRET';

  http.accept = 'application/json';

  const url = 'http://www.inart.com/api/rest/products/store/2?limit=20&page=1';

  let jsonStr: string;
  try {
    jsonStr = await http.quickGetStrAsync(url);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  console.log(`Response status code = ${http.lastStatus}`);

  const json = new JsonObject();
  json.load(jsonStr);
  json.emitCompact = false;

  console.log(json.emit());

  // Use this online tool to generate parsing code from sample JSON: 
  // Generate Parsing Code from JSON
}