OAuthTokenRefresher { protected HttpUriRequest addAuthHeader(HttpUriRequest request) { byte[] base64 = Base64.encode((getClientId() + ":" + getClientSecret()).getBytes(), Base64.DEFAULT); String authorization = new String(base64).replace("\n", "").replace(" ", ""); request.addHeader("Authorization", "Basic " + authorization); request.addHeader("Content-Type", "application/x-www-form-urlencoded"); return request; } OAuthTokenRefresher(); RefreshToken useRefreshToken(String refreshToken); abstract String getTokenUrl(); abstract String getClientId(); abstract String getClientSecret();  }
@Test public void test_addAuthHeader() { HttpUriRequest post = new HttpPost("http: post = refresher.addAuthHeader(post); assertNotNull(post.getFirstHeader("Authorization")); assertEquals("application/x-www-form-urlencoded", post.getLastHeader("Content-Type").getValue()); }