FastOTP-Java-Library facilitates quick and easy development and integration of Java based applications with the FASTOTP API.
Visit FastOTP to get your api key and setup an account. FastOTP Documentation
- Contributors: Oluwatunmise Olatunbosun
- Java 17 or later
- Maven (for building and testing)
To use Java-FastOtp in your project, follow these steps:
- Add the following dependency to your project's
pom.xml
:
<dependencies>
/** Your Other Dependencies */
<dependency>
<groupId>com.oluwatunmise</groupId>
<artifactId>java-fastotp-library-1.0</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
- Configure the repository in your pom.xml:
<distributionManagement>
<repository>
<id>github</id>
<name>Github Oluwatunmise-olat FastOtp Library</name>
<url>https://maven.pkg.github.com/Oluwatunmise-olat/fast-otp-java</url>
</repository>
</distributionManagement>
- Build Project
mvn clean install
- Test
mvn test
Download latest Java-FastOTP Library jar file from here
import com.oluwatunmise.FastOTP;
import com.oluwatunmise.external.*;
public class Main {
public static void main(String[] args) throws Exception {
String apiKey = "xxx_xxx";
FastOTP fastOTP = new FastOTP(apiKey);
OTPDelivery otpDelivery = new OTPDelivery("[email protected]");
GenerateOTP generateOTP = new GenerateOTP(
10,
6,
"alpha_numeric",
"java_test",
otpDelivery
);
BaseResponse baseResponse = fastOTP.GenerateOTP(generateOTP);
if (baseResponse.getSuccess()) {
BaseSuccessResponse baseSuccessResponse = (BaseSuccessResponse) baseResponse.getData();
System.out.println(baseSuccessResponse.getOtp().getDeliveryDetails());
System.out.println(baseSuccessResponse.getOtp().getIdentifier());
}else {
BaseErrorResponse baseErrorResponse = (BaseErrorResponse) baseResponse.getData();
System.out.println(baseErrorResponse.getErrors());
System.out.println(baseErrorResponse.getMessage());
}
}
}
import com.oluwatunmise.FastOTP;
import com.oluwatunmise.external.BaseErrorResponse;
import com.oluwatunmise.external.BaseResponse;
import com.oluwatunmise.external.BaseSuccessResponse;
import com.oluwatunmise.external.ValidateOTP;
public class Main {
public static void main(String[] args) throws Exception {
String apiKey = "xxx_xxx";
FastOTP fastOTP = new FastOTP(apiKey);
ValidateOTP validateOTP = new ValidateOTP("your_identifier", "4567");
BaseResponse baseResponse = fastOTP.ValidateOTP(validateOTP);
if (baseResponse.getSuccess()) {
BaseSuccessResponse baseSuccessResponse = (BaseSuccessResponse) baseResponse.getData();
System.out.println(baseSuccessResponse.getOtp().getDeliveryDetails());
System.out.println(baseSuccessResponse.getOtp().getIdentifier());
}else {
BaseErrorResponse baseErrorResponse = (BaseErrorResponse) baseResponse.getData();
System.out.println(baseErrorResponse.getErrors());
System.out.println(baseErrorResponse.getMessage());
}
}
}
import com.oluwatunmise.FastOTP;
import com.oluwatunmise.external.BaseResponse;
public class Main {
public static void main(String[] args) throws Exception {
String apiKey = "xxx_xxx";
FastOTP fastOTP = new FastOTP(apiKey);
BaseResponse baseResponse = fastOTP.GetOTP("matrix");
System.out.println(baseResponse);
System.out.println(baseResponse.getStatusCode());
System.out.println(baseResponse.getData());
System.out.println(baseResponse.getSuccess());
}
}
The BaseResponse
object provides the following information:
statusCode
: HTTP status code received from fast otp.success
: Indicates whether the response falls within the 200-300 success range.data
: The actual data returned by fast otp.
The MIT License (MIT). Please see License File for more information.
Contributions are welcome! If you find any issues or have enhancements, feel free to open a GitHub issue or submit a pull request.