API Client

Installation

Requirements

  • Java 1.8 or later

Maven users

add this dependency to your project's POM:

<dependency>
    <groupId>in.co.sandbox</groupId>
    <artifactId>api-client</artifactId>
    <version>3.4.1-BUILD-RELEASE</version>
</dependency>

Others

You'll need to manually install the following JARs:

Usage

API Authentication

Instantiate ApiClient with api_key & api_secret. Use this ApiClient to call Paid APIs or to access resources on the server for API users. You can obtain the key from the dashboard.

// Initialize ApiUserCredentials
ApiUserCredentials credentials = new ApiUserCredentials("api_key", "api_secret");

// Initialize ApiClient with API session
ApiClient client =
       ApiClientBuilder.basic().withCredentials(credentials).build();
       
// Use ApiClient to call Paid APIs or to access resources on server for api user
GoodsAndServicesTaxIdentificationNumber gstin = client.GST.GSP.PUBLIC.searchGSTIN(gstin);

OAuth

You can initialize ApiClient with Resource Owner session using OAuth. Use this ApiClient to access resources on server on behalf of resource owner.
Redirection based workflow

Steps:

  1. Navigate to the Quicko OAuth login page with the api_key
  2. A successful login comes back with a request_token to the registered redirect URL
  3. Provide the request_token using OAUTH.authorize
  4. Obtain the access_token and use that to build a ApiClient with resource owner session
// Initialize ApiClient for API User
ApiClient client =
       ApiClientBuilder.basic().withCredentials(new ApiUserCredentials("api_key", "api_secret")).build();
       
// When using Redirection based OAuth workflow, a successful login comes back with a request token 
// to the registered redirect URL. Use that request token to obtain resource owner access token.
String accessToken = client.OAUTH.authorize(requestToken);
       
// Initialize ApiClient with OAuth session
ApiClient resourceOwnerClient =
       ApiClientBuilder.basic().withCredentials(new ApiUserCredentials("api_key", "api_secret")).build(accessToken);
       
// Use ApiClient to call APIs to access resources on server on behalf of resource owner
List<TaxPayer> taxpayers = resourceOwnerClient.IT.TAXPAYER.getTaxPayers(pan);

API based workflow

Steps:

  1. Generate OTP for user using OAUTH.generateOTP
  2. User will obtain an One Time Password (OTP) on their registered email address with validity of 10 mins
  3. Provide the otp and username (user's email) to verify otp using OAUTH.authenticate
  4. Obtain the access_token and use that to build a ApiClient with resource owner session
// Initialize ApiClient for API User
ApiClient client =
       ApiClientBuilder.basic().withCredentials(new ApiUserCredentials("api_key", "api_secret")).build();
       
// When using API based OAuth workflow, generate OTP for resource owner.
client.OAUTH.generateOTP(username);

// Verify OTP for resource owner authentication.
String accessToken = client.OAUTH.authenticate(username, otp);
       
// Initialize ApiClient with OAuth session
ApiClient resourceOwnerClient =
       ApiClientBuilder.basic().withCredentials(new ApiUserCredentials("api_key", "api_secret")).build(accessToken);
       
// Use ApiClient to call APIs to access resources on server on behalf of resource owner
List<TaxPayer> taxpayers = resourceOwnerClient.IT.TAXPAYER.getTaxPayers(pan);

Did this page help you?