I'm completely confused on how this template flows. Using the AccountManager makes complete sense, but how do i get the auth token to include part of the header for calls requiring it ? I have tried to do the following, but i think it's completely the wrong way to go about it
@Override
public void intercept(RequestFacade request) {
// Add header to set content type of JSON
request.addHeader("Content-Type", "application/json");
// Add auth info to request header
AccountManager accountManager = apiKeyProvider.getAccountManager();
Account[] accounts = accountManager.getAccountsByType(Constants.Auth.BOOTSTRAP_ACCOUNT_TYPE);
if (accounts.length != 0) {
String token =
accountManager.peekAuthToken(accounts[0], Constants.Auth.AUTHTOKEN_TYPE);
if (token != null) {
request.addHeader(Constants.Http.HEADER_AUTH_STRING,token);
}
}
// Add the user agent to the request.
request.addHeader("User-Agent", userAgentProvider.get());
}