### Question:
ClientAuthInterceptor implements ClientInterceptor { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, final Channel next) { return new CheckedForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) { @Override protected void checkedStart(Listener<RespT> responseListener, Metadata headers) throws StatusException { Metadata cachedSaved; URI uri = serviceUri(next, method); synchronized (ClientAuthInterceptor.this) { Map<String, List<String>> latestMetadata = getRequestMetadata(uri); if (lastMetadata == null || lastMetadata != latestMetadata) { lastMetadata = latestMetadata; cached = toHeaders(lastMetadata); } cachedSaved = cached; } headers.merge(cachedSaved); delegate().start(responseListener, headers); } }; } ClientAuthInterceptor(
      Credentials credentials, @SuppressWarnings("unused") Executor executor); @Override ClientCall<ReqT, RespT> interceptCall(
      final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, final Channel next);  }### Answer:
@Test public void testWithOAuth2Credential() { final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE)); final OAuth2Credentials oAuth2Credentials = new OAuth2Credentials() { @Override public AccessToken refreshAccessToken() throws IOException { return token; } }; interceptor = new ClientAuthInterceptor(oAuth2Credentials, executor); ClientCall<String, Integer> interceptedCall = interceptor.interceptCall(descriptor, CallOptions.DEFAULT, channel); Metadata headers = new Metadata(); interceptedCall.start(listener, headers); assertEquals(listener, call.responseListener); assertEquals(headers, call.headers); Iterable<String> authorization = headers.getAll(AUTHORIZATION); Assert.assertArrayEquals(new String[]{"Bearer allyourbase"}, Iterables.toArray(authorization, String.class)); }