简体   繁体   中英

java.lang.ClassNotFoundException: com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier$Builder

I'm trying to add a Google sign-in button in my Java Web Application project. I'm trying to receive in Servlet back-end an id token using GoogleIdTokenVerifier , following Google Guides:https://developers.google.com/identity/sign-in/web/backend-auth . Everything for Eclipse is okay, but running my project using Tomcat v9 and arriving to the point:

final HttpTransport transport = new NetHttpTransport();
final JsonFactory jsonFactory = new GsonFactory();// tried it with jsonFactory = new JsonFactory();
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport, jsonFactory).setAudience(id_singleton).build();

Eclipse gives me this error:

SEVERE: Servlet.service() for servlet [controller.GoogleTokenSignIn] in context with path [/Project] threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier$Builder.

I turned over all the stack overflow and I found an answer which says to update the jars. I have the google api release 1.30.9 jars and 1.30.6 or the oauth and still giving same error.

I don't know how to show my eclipse configuration: Run configuration Server Arguments Classpath . I hope it's clear now.

Take the jar files that causes the issue and extract them, take source and put it in the same directory of your project /project/src manually. It should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM