package com.google.sps.data;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.BufferedReader;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

public class RequestParser {
  
    public static <T> T parseObjectFromRequest(HttpServletRequest request, Class<T> type) throws IOException, JsonSyntaxException {
        return (new Gson()).fromJson(parseStringFromRequest(request), type);
    }

    public static String parseStringFromRequest(HttpServletRequest request) throws IOException, JsonSyntaxException {
        BufferedReader reader = request.getReader();
        StringBuilder sb = new StringBuilder();
        try {
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
        } finally {
            reader.close();
        }
        return sb.toString();
    }
}
@@ -22,16 +22,17 @@
 s.data;%0A
+%0A
 import j
@@ -239,16 +239,280 @@
 ception;
+%0Aimport com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;%0Aimport com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload;%0Aimport com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;%0Aimport java.security.GeneralSecurityException;
 %0A%0Apublic
@@ -1165,32 +1165,32 @@
 se();%0A        %7D%0A
-
         return s
@@ -1208,10 +1208,643 @@
 );%0A    %7D
+%0A%0A    public static GoogleIdToken verifyTokenFromRequest(HttpServletRequest request) throws IOException, GeneralSecurityException %7B    %0A        GoogleIdToken idToken = tokenVerifier().verify(RequestParser.parseStringFromRequest(request));%0A        if (idToken != null)%7B%0A            return idToken;%0A        %7D else %7B%0A            throw new GeneralSecurityException();%0A        %7D%0A    %7D%0A %0A    private static GoogleIdTokenVerifier tokenVerifier() %7B%0A        return new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), new JacksonFactory())%0A            .setAudience(Collections.singletonList(Config.CLIENT_ID))%0A            .build();%0A    %7D
 %0A%7D

Add verify helper functions to RequestParser.java