GoogleAuth { public static boolean isOAuth2Token(String token) { if (token == null) { return false; } String strippedToken = token.trim().replaceFirst("^['\"]", ""); for (String prefix : OAUTH2_TOKEN_PREFIXES) { if (strippedToken.startsWith(prefix)) { return true; } } return false; }  static String getAuthToken(HttpServletRequest request); static boolean isJwt(String token); static boolean isOAuth2Token(String token); static TokenInfo getTokenInfoRemote(String token);  }
@Test public void testIsOAuth2Token() { for (String prefix : GoogleAuth.OAUTH2_TOKEN_PREFIXES) { assertTrue(GoogleAuth.isOAuth2Token(prefix + "abc")); assertFalse(GoogleAuth.isOAuth2Token("x" + prefix + "abc")); } }