GoogleAuth { public static String getAuthToken(HttpServletRequest request) { if (request.getAttribute(Attribute.AUTH_TOKEN) == null) { String token = getAuthTokenFromHeader(request.getHeader(AUTHORIZATION_HEADER)); if (token == null) { token = getAuthTokenFromQueryParameters(request); } request.setAttribute(Attribute.AUTH_TOKEN, token); } return (String) request.getAttribute(Attribute.AUTH_TOKEN); }  static String getAuthToken(HttpServletRequest request); static boolean isJwt(String token); static boolean isOAuth2Token(String token); static TokenInfo getTokenInfoRemote(String token);  }
@Test public void testGetAuthToken_fromHeaders() { for (String scheme : GoogleAuth.ALLOWED_AUTH_SCHEMES) { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader(GoogleAuth.AUTHORIZATION_HEADER, scheme + " some-value"); assertEquals("some-value", GoogleAuth.getAuthToken(request)); } MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader(GoogleAuth.AUTHORIZATION_HEADER, "noSuchAuthScheme some-value"); assertNull(GoogleAuth.getAuthToken(request)); }