class CloudShellCredential extends GoogleCredential {

  @Override
  protected TokenResponse executeRefreshToken()
      throws IOException {
    Socket socket = new Socket("localhost", this.getAuthPort());
    socket.setSoTimeout(READ_TIMEOUT_MS);
    TokenResponse token = new TokenResponse();
    try {
      PrintWriter out =
        new PrintWriter(socket.getOutputStream(), true);
      out.println(GET_AUTH_TOKEN_REQUEST);

      BufferedReader input =
          new BufferedReader(new InputStreamReader(socket.getInputStream()));
      // Ignore the size line
      input.readLine();

      Collection<Object> messageArray = jsonFactory.createJsonParser(input)
        .parseArray(LinkedList.class, Object.class);
      String accessToken = ((List<Object>) messageArray).get(ACCESS_TOKEN_INDEX).toString();
      token.setAccessToken(accessToken);
    } finally {
      socket.close();
    }
    return token;
  }

  public  CloudShellCredential(int authPort, JsonFactory jsonFactory);

}