private String getUserToken(GoogleCredential credential) throws IOException { log.debug("Fetching user access token"); final TokenRequest request = new RefreshTokenRequest( this.httpTransport, JSON_FACTORY, new GenericUrl(credential.getTokenServerEncodedUrl()), credential.getRefreshToken()) .setClientAuthentication(credential.getClientAuthentication()) .setRequestInitializer(credential); final TokenResponse response = request.execute(); return (String) response.get("id_token"); }
private String getServiceAccountToken(GoogleCredential credential, String targetAudience) throws IOException, GeneralSecurityException { log.debug("Fetching service account access token for {}", credential.getServiceAccountUser()); final TokenRequest request = new TokenRequest( this.httpTransport, JSON_FACTORY, new GenericUrl(credential.getTokenServerEncodedUrl()), "urn:ietf:params:oauth:grant-type:jwt-bearer"); final Header header = jwtHeader(); final Payload payload = jwtPayload( targetAudience, credential.getServiceAccountId(), credential.getTokenServerEncodedUrl()); request.put("assertion", JsonWebSignature.signUsingRsaSha256( credential.getServiceAccountPrivateKey(), JSON_FACTORY, header, payload)); final TokenResponse response = request.execute(); return (String) response.get("id_token"); }
.setRequestInitializer(getRequestInitializer()); request.put("assertion", assertion); return request.execute(); } catch (GeneralSecurityException exception) { throw (IOException) new IOException().initCause(exception);
.setRequestInitializer(getRequestInitializer()); request.put("assertion", assertion); return request.execute(); } catch (GeneralSecurityException exception) { throw (IOException) new IOException().initCause(exception);
"urn:ietf:params:oauth:grant-type:jwt-bearer"); request.put("assertion", assertion); return request.execute(); } catch (GeneralSecurityException exception) { IOException e = new IOException();