KeyStore keyStore = KeyStore.getInstance("PKCS12"); keyStore.load(new FileInputStream(P12_FILE), "notasecret".toCharArray()); java.security.PrivateKey privateKey = (java.security.PrivateKey) keyStore.getKey("privatekey", "notasecret".toCharArray()); PrivateKey pk = new PrivateKey(privateKey); JWT jwt = new JWT.Builder() .setClaimsSetIssuer("788732372078-pas6c4tqtudpoco2f4au18e00suedjtb@developer.gserviceaccount.com") .setClaimsSetCustomField("scope", " https://www.googleapis.com/auth/plus.login") .setClaimsSetAudience("https://accounts.google.com/o/oauth2/token") .setClaimsSetIssuedAt(System.currentTimeMillis() / 1000) .setClaimsSetExpirationTime(System.currentTimeMillis() / 1000 +3600) .build(); String payload = new JWTClaimsSetWriter().write(jwt.getClaimsSet()); JWS jws = new JWS.Builder() .setType("JWT") .setAlgorithm(JwsConstants.RS256) .setPayload(payload).sign(new SignatureMethodRSAImpl(JwsConstants.RS256), pk).build(); System.out.println("your assertion is "+new JWSWriter().write(jws));