Java
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.
Steps:
- Navigate to the Quicko OAuth login page with the
api_key
- A successful login comes back with a
request_token
to the registered redirect URL - Provide the
request_token
using OAUTH.authorize - 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<Business> businesses = resourceOwnerClient.GST.BUSINESS.getBusinesses(gstin);
Steps:
- Generate OTP for user using OAUTH.generateOTP
- User will obtain an One Time Password (OTP) on their registered email address with validity of 10 mins
- Provide the otp and username (user's email) to verify otp using OAUTH.authenticate
- 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<Business> businesses = resourceOwnerClient.GST.BUSINESS.getBusinesses(gstin);
Updated 3 months ago