onfido / onfido-java Goto Github PK
View Code? Open in Web Editor NEWJava library for the Onfido API
Home Page: https://documentation.onfido.com/
License: MIT License
Java library for the Onfido API
Home Page: https://documentation.onfido.com/
License: MIT License
Hi,
It's not a bug, but in the Documentation, a section dedicated of workflow run is described here : Workflow Runs
But it's completely missing from the Java library.
Is it normal ?
Thanks, have a nice day.
Can you please provide a Java example of building the Applicant.Request with consents field
This [art is missing at the API documentation https://documentation.onfido.com/#create-applicant
I tried something like this:
var applicantRequest = Applicant.request()
.firstName(firstName)
.lastName(lastName)
.location(location)
.consents("{\"name\":\"privacy_notices_read\",\"granted\":true}");
var consent = new Consent().setName("privacy_notices_read").setGranted(true);
var moshi = new Moshi.Builder().build();
JsonAdapter<Consent> jsonAdapter = moshi.adapter(Consent.class);
var applicantRequest = Applicant.request()
.firstName(firstName)
.lastName(lastName)
.location(location)
.consents(jsonAdapter.toJson(consent));
where Consent
@Data
@Accessors(chain = true)
public class Consent {
String name;
boolean granted;
}
And for all getting the Something went wrong, fields{}
error message
https://documentation.onfido.com/#autofill-beta
The auto fill api will return DateTimeParseException if the date of birth value is empty string.
java.time.format.DateTimeParseException: Text '' could not be parsed at index 0 at $.extracted_data.date_of_birth
In code:
package com.onfido.api;
..
public final class ApiJson {
private static final class LocalDateAdapter {
...
/**
* Converts a json string to a LocalDate.
*
* @param dateString the date string
* @return the local date
*/
@FromJSON
LocalDate fromJson(String dateString) {
return dateString == null ? null : LocalDate.parse(dateString);
}
}
must check if the dateString is empty or null, then return null
From the doc: https://documentation.onfido.com/#create-check-request-body
privacy_notices_read_consent_given
optional
Boolean to indicate that the privacy notices and terms of service have been read and, where specific laws require, that consent has been given for Onfido. This parameter should be set to true after gaining the necessary consent, and if it's set to false the request will fail with a validation error. If this parameter is omitted when creating the check, it will be returned as null in the check response object.
in code:
@Json(name = "privacy_notices_read_consent_given") private final boolean privacyNoticesReadConsentGiven;
This results in error
com.squareup.moshi.JsonDataException: Expected a boolean but was NULL at path $.privacy_notices_read_consent_given
Hi Im using the java client to create an applicant like this
<dependency>
<groupId>com.onfido</groupId>
<artifactId>onfido-api-java</artifactId>
<version>1.3.1</version>
</dependency>
Onfido onfido = Onfido.builder()
.apiToken(token)
.build();
Applicant createApplicant = onfido.applicant.create(
Applicant.request()
.firstName(applicantRequest.getFirstname())
.lastName(applicantRequest.getLastname())
.dob(applicantRequest.getBirthdate())
.idNumbers(IdNumber.request().value(applicantRequest.getDocumentIdNumber()))
);
but it's giving me this error:
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.demetra.core.logging.rest.CustomURLFilter.doFilter(CustomURLFilter.java:36)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
at com.onfido.api.ResourceManager.post(ResourceManager.java:38)
at com.onfido.ApplicantManager.create(ApplicantManager.java:31)
any idea where Im wrong?
Documentation:
https://documentation.onfido.com/#document-report
"documents": [
{
"id": "<DOCUMENT_ID>"
}
]
"documents" property should contain list of objects with id inside, but not a list of strings.
https://documentation.onfido.com/document-report-object/ defines read_id_compliance
report property as a String
:
But something like:
String realIdCompliance = new ApiJson(Report.class).parse(reportJsonString).getProperties().get("real_id_compliance")
where reportJsonString
is an actual report retrieval response from Onfido API containing this property, will return it as a Boolean
and blow up on cast exception instead of returning the expected String
type value.
Either the documentation, the Onfido API response, or this java client should be fixed for all three to be aligned.
P.S: This was tested on onfido-api-java 2.5.0 & kotlin-stdlib 1.4.21
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
When I rolled back to JAR 1.3.1 this works fine with onfido v3.2
I am creating a check with the applicant id received by creating an onfido applicant. Afterwards, I create a check using this id and the new document_ids field released in v1.3.1 and I always receive the error with code 422, Document(s) don't belong to applicant.
It would be great to have possibility to inject custom OkHttpClient via builder.
For example, in case if we need to intercept each API call for audit purposes.
maven-enforcer-plugin
with <dependencyConvergence/>
turned on returns following report for onfido-api-java
library:
[WARNING]
Dependency convergence error for com.squareup.okio:okio:1.13.0 paths to dependency are:
+-<my lib and version here>
+-com.onfido:onfido-api-java:1.3.1
+-com.squareup.okhttp3:okhttp:3.8.1
+-com.squareup.okio:okio:1.13.0
and
+-<my lib and version here>
+-com.onfido:onfido-api-java:1.3.1
+-com.squareup.moshi:moshi:1.8.0
+-com.squareup.okio:okio:1.16.0
2 different versions of com.squareup.okio:okio
is used in dependency tree of onfido-api-java:1.3.1
I can exclude one of them on my side as a temporary solution but it would be nice to have this dependency version consistent.
Thanks in advance, Kacper
The v3 API is documented to continue the v2 API's ability to specify which of the uploaded documents will be used in performing a check:
https://developers.onfido.com/guide/api-v2-to-v3-migration-guide#document-ids-in-the-document-report
However there is not an option to set those using the java client. Expecting to be able to do something like,
Check.request().applicantId(applicantId).reportNames(reportNames).documentIds(documentIds)
Hi Team,
I'm trying to download a document with Java SDK, however I always receive an empty InputStream with status "Closed". I'm getting same behaviour with selfie and video download.
Below the snippet of code with what I'm doing.
public static void main(String[] args) {
FileDownload download;
try {
download = downloadDocument("DOCUMENT_ID");
InputStream document = download.content;
byte[] buffer = new byte[document.available()];
document.read(buffer);
File targetFile = new File("temp.jpg");
OutputStream outStream = new FileOutputStream(targetFile);
outStream.write(buffer);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Finished");
}
public static FileDownload downloadDocument(final String documentId) throws OnfidoException {
final Onfido onfido = createOnfidoClient();
return onfido.document.download(documentId);
}
private static Onfido createOnfidoClient() {
return Onfido.builder()
.apiToken("API_TOKEN")
.build();
}
This is the Stack Trace:
java.io.IOException: closed
at okio.RealBufferedSource$inputStream$1.available(RealBufferedSource.kt:446)
at com.company.Main.main(Main.java:19)
Thanks a lot for your help,
Best
Andrea
Onfido Autofill Beta APIs gives OCR capabilities. Can we have them integrated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.