如何在后端集成Google身份验证?

时间:2018-10-05 17:24:38

标签: java oauth google-oauth google-plus google-signin

我正在使用以下代码在后端验证user access token

private static final HttpTransport transport = new NetHttpTransport();
private static final JsonFactory jsonFactory = new JacksonFactory();


public static boolean googleAccessTokenValidation(String inputToken) throws Exception {
  GoogleIdTokenVerifier googleIdTokenVerifier = new GoogleIdTokenVerifier.Builder(transport, jsonFactory)
          .setAudience(Collections.singletonList(Constant.GOOGLE_CLIENT_ID)).build();

  GoogleIdToken idToken = googleIdTokenVerifier.verify(inputToken);
  if (idToken != null) {
        return true;
  } else return false;
}

clientIDAudience的位置是 Web客户端(为Google登录自动创建)

我将sbt用于依赖项并导入

"com.google.api-client" % "google-api-client" % "1.25.0","com.google.api.client" % "google-api-client-auth-oauth2" % "1.2.3-alpha",

所有这些之后,我得到以下错误:

无法解析com.google.api.client.auth.openidconnect.IdTokenVerifier.Builder。我在这里做错了什么?

0 个答案:

没有答案