google / java-photoslibrary

Java client library for the Google Photos Library API
http://developers.google.com/photos
Apache License 2.0
108 stars 59 forks source link

Failed to create JWT helper. #19

Closed UnknownSilicon closed 5 years ago

UnknownSilicon commented 5 years ago

When using the java-photoslibrary api with the following dependencies, the error

java.lang.NoSuchMethodException: com.google.auth.oauth2.ServiceAccountJwtAccessCredentials.<init>(java.lang.String, java.lang.String, java.security.PrivateKey, java.lang.String)
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.getConstructor(Class.java:1825)
    at io.grpc.auth.GoogleAuthLibraryCallCredentials$JwtHelper.<init>(GoogleAuthLibraryCallCredentials.java:270)
    at io.grpc.auth.GoogleAuthLibraryCallCredentials.createJwtHelperOrNull(GoogleAuthLibraryCallCredentials.java:221)
    at io.grpc.auth.GoogleAuthLibraryCallCredentials.<clinit>(GoogleAuthLibraryCallCredentials.java:54)
    at io.grpc.auth.MoreCallCredentials.from(MoreCallCredentials.java:35)
    at com.google.api.gax.grpc.GrpcCallContext.withCredentials(GrpcCallContext.java:131)
    at com.google.api.gax.grpc.GrpcCallContext.withCredentials(GrpcCallContext.java:64)
    at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:165)
    at com.google.photos.library.v1.internal.stub.GrpcPhotosLibraryStub.create(GrpcPhotosLibraryStub.java:286)
    at com.google.photos.library.v1.internal.stub.PhotosLibraryStubSettings.createStub(PhotosLibraryStubSettings.java:264)
    at com.google.photos.library.v1.internal.InternalPhotosLibraryClient.<init>(InternalPhotosLibraryClient.java:180)
    at com.google.photos.library.v1.PhotosLibraryClient.<init>(PhotosLibraryClient.java:101)
    at com.google.photos.library.v1.PhotosLibraryClient.initialize(PhotosLibraryClient.java:114)
    at photosAPI.Photos.<init>(Photos.java:58)
    at Main.main(Main.java:26)

is thrown. This seems to be due to an out of date version of the com.google.api:gax dependency. Currently, version 1.43 is used. When I forced gradle to use version 1.44 of the api, the issue was resolved.

I reccomend changing the version from 1.43 to 1.44 on https://github.com/google/java-photoslibrary/blob/9230526ed31b19aa89960215b38a3f5a4729fcea/photoslibraryapi/build.gradle#L50

Depdendencies:

   compile 'com.google.photos.library:google-photos-library-client:1.2.0'
    compile 'com.google.api-client:google-api-client:1.28.0'
    compile 'io.grpc:grpc-netty-shaded:1.20.0'
    compile 'io.grpc:grpc-protobuf:1.20.0'
    compile 'io.grpc:grpc-stub:1.20.0'
    compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.28.0'
    compile group: 'com.google.oauth-client', name: 'google-oauth-client-java6', version: '1.28.0'
jfschmakeit commented 5 years ago

Thanks - looks like something went out of date between the authentication library and gax-grpc. We'll bump all dependencies in the next library release that should be coming shortly.

jfschmakeit commented 5 years ago

This should be fixed in the latest release - can you try this again with version 1.3.0?

(Thanks for preparing a pull request, but unfortunately we had to verify and bump a few other dependencies at the same time.)

UnknownSilicon commented 5 years ago

That seems to have fixed it, thanks for the help!