JavaScript SDK

Powerful, customized verification in your web app

JavaScript

Create a custom verification integration in your app. Upon positive verification, receive a unique token to send to our REST API for validation.

REST API

Positive verifications result in a unique access token, which you can securely pass to our REST API for validation and identifying information about the User.

Who should use the JS-SDK?

Most businesses using ID Services to offer a verified discount don’t need the JS-SDK. Easier options exist, including customized landing pages or copy/paste code snippets.

However, some businesses prefer the custom functionality of a Software Development Kit.

The JS-SDK could allow your business to enable identity verification tailored to your specific workflow. If you’ve checked out our standard services and it isn’t quite what you’re looking for, it’s possible the JS-SDK is what you need.

HTML / JavaScript

The verification popup is cross-browser compatible across all major browsers. Use the JS-SDK to authenticate Users with ID Services, resulting in an access token you can send to our REST API for validation.

CDN

<script src="https://cdn.id.services/js-sdk/api.js"></script>

This is the only script you need to integrate the JS-SDK.

HTML

<button type="button" id="myBtn">Open</button>

Basic Example

IDSRV.verify({
  pub_key: "{your public key}",
  initializer: document.getElementById("myBtn"),
  onSuccess: function(token){
    console.log(token); //Send to REST API
  }
});

Required Parameters

Name Description
initializer (HTML Object). Elements assigned to launch verification. Can be a single element getElementById() or array of elements getElementsByClassName(). Also compatible with jQuery, for example $(“#myBtn”) or $(“.myClass”).
onSuccess (Function). Handles the return of a token, which is passed as a String. In most cases, you’ll perform either AJAX or a standard POST request to your app with the token to be validated via IDS REST API.
pub_key (String). Public key is found in your account page after enrolling in a Plan.

Optional Parameters

Name Description
forceLogin (Boolean). After a verification popup is closed, default behavior is to force Users to re-login. Default is true.
message (String). Message to User prior to verification. This will override the default Message from your IDS Account. Note: company name is only modifiable from within your account.
onClose (Function). Callback for popup closing without a positive verification. Important: this does not mean the User was “rejected”. It simply means the User closed the popup prior to completing verification.
onLoad (Function). Callback for popup load success. This means your Public Key was accepted and the User reached login prompt.

REST API

Validate your User access token from the JS-SDK. All responses are in JSON.

Endpoint

POST https://api.id.services/user/{token}

Required Parameters

Name Description
private_key (String). Private Key is from your account. Private Key must be from the same initiating account Public Key belonged in the JS-SDK.

Response

{
  "email": "customer@example.com",
  "first_name": "John",
  "last_name": "Smith",
  "verified": true
}

Errors

{
  "error": "Invalid token."
}

Get in touch

If we didn’t answer all of your questions, feel free to drop us a line.

support@id.services