I'm implementing the one-tap signIn for my site. With the normal Google SignIn, i can do this:
window.gapi.auth2.getAuthInstance().signIn()
.then((googleUser) => sendAccessTokenToServer(googleUser.getAuthResponse().access_token))
Thanks to access_token, on the server side I can do something like this and get profile informations like gender:
GoogleCredential.Builder()
.setTransport(httpTransport).setJsonFactory(jsonFactory)
.setClientSecrets(clientId, secret).setRequestInitializer((request -> {
HttpHeaders headers = request.getHeaders();
headers.setAuthorization("Bearer " + accessToken);
})).build();
But when using the googleyolo, with hint() or retrieve() i cannot get the access_token, but just the idToken: googleyolo
.hint({
supportedAuthMethods: [googleUrl, 'googleyolo://id-and-password', scope],
supportedIdTokenProviders: [
{
uri: googleUrl,
clientId
}]
}).then(
(credential) => {
if (credential.idToken) {
sendidTokenToServer(credential.idToken);
}
}
But the problem is, when i do on server-side:
GoogleIdToken idToken = null;
try {
idToken = verifier.verify(accessToken);
} catch (Exception e) {
e.printStackTrace();
}
if (idToken != null) {
GoogleIdToken.Payload payload = idToken.getPayload();
// Print user identifier
String userId = payload.getSubject();
System.out.println("User ID: " + userId);
// Get profile information from payload
String email = payload.getEmail();
boolean emailVerified = Boolean.valueOf(payload.getEmailVerified());
String name = (String) payload.get("name");
String pictureUrl = (String) payload.get("picture");
String locale = (String) payload.get("locale");
String familyName = (String) payload.get("family_name");
String givenName = (String) payload.get("given_name");
I don't get informations like the gender. Is it possible to get an access_token from googleyolo or getting the gender inside the idToken?