jQuery Example to Generate an Access Token

Modified on Thu, 14 Sep, 2023 at 2:52 PM

You can generate a token suitable for supply queries by making a POST request to the Nexar identity server. There are a number of examples in our public GitHub samples (and a cURL example), but here is a snippet of jQuery code you can utilise on front-end applications. 

var settings = {
  "url": "https://identity.nexar.com/connect/token",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded"
  "data": {
    "client_id": "<your_client_id>",
    "client_secret": "<your_client_secret>",
    "grant_type": "client_credentials"

$.ajax(settings).done(function (response) {

The response should be similar to the following:

The response should be similar to this:
    "access_token": "<your_access_token>",
    "expires_in": 86400,
    "token_type": "Bearer",
    "scope": "supply.domain"

Warning : For performance reasons and to reduce the pressure on our identity service, please cache the access token (valid by default for up to 24 hours) rather than generate a new token for every query.

Be sure to replace the <your_client_id> and <your_client_secret> fields with your Nexar application client information.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article