Our APIs use the Bearer token authentication method. The token can be generated in 2 ways:

  1. By API
  2. Using the cookie

Generating the token via API

We have an Log In/Get Admin Token API that responds with a user's access_token which can be used as token to authenticate our APIs. The API takes Client ID and Client Secret as input. See the API's details in the link.

POST Log In/Get Admin Token
https://{{your-marketplace}}.arcadier.io/token

Documentation of this API can be found here.


EXAMPLE REQUEST IN jQuery:


var settings = {
  "url": "https://{{your-marketplace}}.arcadier.io/token",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  },
  "data": {
    "client_id": "",
    "client_secret": "",
    "grant_type": "client_credentials",
    "scope": "admin"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
);


EXAMPLE RESPONSE:


{
  "access_token": "W0epUTVx5oFTadxY7mqiJIiXFIxd1C-RI8P9Ll-K29l4mT2lF0of933_gAtVcwxsBkLk4tC3a3yNidzH6wk2YdieHoM-JwmrblrDgTT8-bhE04MNktzmPlZmIYDwvzo2Ad5f5LRwP8DI9gAfQ4RmeSBm35pWbC7raZS0zTVAiKCf0-K9wJsMiwOnqfjtseb80HTCazEFZHcUGKzeoPw1dWeGRQ2U3vQ__LZtG1eLzz2ivUpW2vG69zN8DINlZCrL_GNknM0oosXvhTehLWM7Jt6P-PNYzvZUCPBJHRcVSOM4WV_v3Du7ZCy2gXRmmXAEFqeacGkcTJHRz1DVM3gR9kFlaBmMSAIFC_vKSrmzn6FhZ9mSXXWbtUsfHLh7cpa1k0IcYhCzLsfZ_32J3uSK6gd3UpT_ijJOmc_tVjPImdFDcxSTXc_JhfiNFqhJ9C8mRGSEZZykS8I3wi3QwGVLuFFwgU5fXmEnE10bxeuVVI3HYXl-Z6wx7I0KnVM6rcGF7fPh5-d9pVffnBoTYyld_palMyOf1OtnjHD-n4OLwLmkRUPnuq2Bs54CEau0_qFd4r71GlgLeZr-gBUIqLyOcDwk0IsgIuz2eDE37V_LHGUBuj68cc-yM5dR-MqaBkRJ1wpxjgTPeApFs67v9RYAONTtsdfwvuY7odsaGQvdG9owednDKKiv7lNOX7buzgXZSXeQklXYZScBp_gbl_16KdigQxPLYSn02j1THdNir_Dt2DofNBMv2qpmslgSbd7iFSVaKA",
  "token_type": "bearer",
  "expires_in": 10799,
  "refresh_token": "98b93750a4054d8db242e5ab4491c323",
  "UserId": "e1676334-1724-45e3-b5fd-5481a3537b45"
}

Fetching the token from Cookie 

Tokens can also be obtained using the snippet below. If the code is running on client side, then it can get the user's token from the cookie stored locally. It is passed as a parameter using the Bearer + token method.

function getCookie(name){
    var value = '; ' + document.cookie;
    var parts = value.split('; ' + name + '=');
    if (parts.length === 2) {
        return parts.pop().split(';').shift();
    }
}

var token = getCookie('webapitoken');


This token can now be used throughout your script every time it's run.



Was this article helpful?
1 out of 1 found this helpful