Skip to content

gridy-java-client

Requirements

Building the API client library requires:

  • Java 1.8+
  • Maven (3.8.3+)/Gradle (7.2+)

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>io.gridy</groupId>
  <artifactId>gridy-java-client</artifactId>
  <version>1.0.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
    mavenCentral() 
  }

  dependencies {
     implementation "io.gridy:gridy-java-client:1.0.0"
  }

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/gridy-java-client-1.0.0.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

  import io.gridy.client.ApiClient;
  import io.gridy.client.ApiException;
  import io.gridy.client.Configuration;
  import io.gridy.client.auth.HmacSha512Auth;
  import io.gridy.client.model.*;
  import io.gridy.client.api.GridyIdServiceApi

  ApiClient defaultClient = new ApiConfig.Builder()             
         # Configure API User Id                       
        .withApiUser( System.getEnv("GRIDY_API_USER")  )                
         # Configure API User Secret
        .withApiSecret( System.getEnv("GRIDY_API_SECRET")  )                
         # Configure API Environment
        .withApiEnv(GridyEnv.LIVE)
            .build(); 

  GridyIdServiceApi apiInstance = new GridyIdServiceApi(defaultClient);
      ApiRequest apiRequest = new ApiRequest()
            .id("YOUR ID REFERENCE")
            .apiUser( defaultClient.getApiUser() )
            .type(ApiReqstType.CHALLENGE_NEW )
            .body( new ChallengeRequest.Builder()                      
                .forUser( "<USER EMAIL ADDRESS>" )
                .challengeType( ChallengeType.UserKeyAndPattern ) 
                .enableAutoVerify( false )
                .enableQRcode( true )    
                .withExpiry( Expiry.ThirtyMins  )
                .withStatus( Status.NEW )
                .withProfile( Profile.DEFAULT )
                .withIPAddress("")
                .build().toJson()
               );

      try {

        ModelApiResponse result = apiInstance.challenge(apiRequest);
        System.out.println(result);

      } catch (ApiException e) {

        System.err.println("Exception when calling GridyIdServiceApi#challenge");
        System.err.println("Status code: " + e.getCode());
        System.err.println("Reason: " + e.getResponseBody());
        System.err.println("Response headers: " + e.getResponseHeaders());

        e.printStackTrace();
}

Documentation & Examples for API Endpoints

All URIs are relative to https://api.gridy.io

Class Method HTTP request Description
GridyIdServiceApi challenge POST /v1/svc/challenge Send or Cancel a Gridy ID MFA challenge request.
GridyIdServiceApi verify POST /v1/svc/verify Verify a Gridy ID authentication code
GridyIdServiceApi status POST /v1/svc/status Check a Gridy ID MFA challenge status
GridyIdServiceApi time POST /v1/svc/time Get current UTC time
GridyIdServiceApi blocked POST /v1/svc/blocked Check API User defined Blocked Rule

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.