无法在g + api中验证id令牌

时间:2018-06-17 17:24:18

标签: java api jsp google-app-engine oauth

你好任何人都可以帮助我吗?

  

public static GoogleIdToken.Payload getPayload(String tokenString)   抛出异常{

    JacksonFactory jacksonFactory = new JacksonFactory();
    GoogleIdTokenVerifier googleIdTokenVerifier =
                        new GoogleIdTokenVerifier(new NetHttpTransport(),jacksonFactory);

    GoogleIdToken token = GoogleIdToken.parse(jacksonFactory, tokenString);
    System.out.println(token);
    if (googleIdTokenVerifier.verify(token)) {

        GoogleIdToken.Payload payload = token.getPayload();
        if (!GOOGLE_CLIENT_ID.equals(payload.getAudience())) {
            throw new IllegalArgumentException("Audience mismatch");
        } else if (!GOOGLE_CLIENT_ID.equals(payload.getAuthorizedParty())) {
            throw new IllegalArgumentException("Client ID mismatch");
        }
        return payload;
    } else {
        throw new IllegalArgumentException("id token cannot be verified");
    }
}

GoogleIdTokenVerifier.verify()方法返回false。但令牌是他们的。 请求帮助我.................................

0 个答案:

没有答案