Java – Google login Google idtoken backend verification fails suddenly
•
Java
I've always had this problem with Google login I have an Android application connected by users to authenticate with Google and send idtoken to my server The server uses the Google idtoken verifier to verify the token
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport,jsonFactory)
.setAudience(audience)
.setIssuer("https://accounts.google.com")
.build();
GoogleIdToken idToken = null;
try {
idToken = verifier.verify(idTokenString);
} catch (Exception e) {
e.printStackTrace();
}
if (idToken != null) {
GoogleIdToken.Payload payload = idToken.getPayload();
String userId = payload.getSubject();
System.out.println("User ID: " + userId);
String email = payload.getEmail();
System.out.println("Emaail:" + email);
return userId;
} else {
System.out.println("Invalid ID token.");
return null;
}
This worked for a while, and then suddenly the validation started always failing Nothing has changed! Any ideas?
Solution
Checking the server time, I encountered the same problem when migrating to a new server I solve the problem by setting the time zone using NTP
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
