I am trying to get Access token using Angular 4. When the user logIn using Google I get the following Data.
authToken // *
id
email
.
.
.
name
I think that the variable
authToken
is not theaccess token
because when I try to verify it using the following code ( spring boot),GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance()) .setAudience(Collections.singletonList( "ID_CLIENT") .build(); try { GoogleIdToken idToken = verifier.verify(accessToken); if (idToken != null) { Payload payload = idToken.getPayload(); String userId = payload.getSubject(); System.out.println("User ID: " + userId); 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"); System.out.println(accessToken); return accessToken; } else { System.out.println("null"); return "**this is not a valid Token**"; } } catch (IllegalArgumentException e) { return "IllegalArgumentException"; }
it return
IllegalArgumentException
So how I can get Google access token using Angular