GithubHelp home page GithubHelp logo

onfido-java's People

Contributors

akrasnoshchok avatar ciaran16 avatar davidmealha avatar dependabot[bot] avatar djiang-onfido avatar dvacca avatar enesdogan27 avatar eraxyz avatar gordeevnm avatar jakebat avatar joaogoncalves-onfido avatar lotr avatar mkhairuddin avatar phoebe-b avatar r4md4c avatar ra-ul avatar serbioboeronfido avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onfido-java's Issues

What is the proper request for Applicant creation with consents?

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

Empty string of LocalDate is not handled

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

privacyNoticesReadConsentGiven field does not correspond API

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

okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)

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?

Invalid Boolean type instead of String returned when parsing read_id_compliance report property

https://documentation.onfido.com/document-report-object/ defines read_id_compliance report property as a String:
image

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

maven-enforcer-plugin warns for onfido-api-java

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

Empty InputStream with status "Closed" when trying to download document, selfie or video from Onfido

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.