protected void addOAuthAuthorizationHeader(HttpURLConnection connection) throws OsmTransferException {
if (oauthParameters == null) {
oauthParameters = OAuthParameters.createFromPreferences(Main.pref);
}
OAuthConsumer consumer = oauthParameters.buildConsumer();
OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
if (! holder.containsAccessToken())
throw new MissingOAuthAccessTokenException();
consumer.setTokenWithSecret(holder.getAccessTokenKey(), holder.getAccessTokenSecret());
try {
consumer.sign(connection);
} catch(OAuthException e) {
throw new OsmTransferException(tr("Failed to sign a HTTP connection with an OAuth Authentication header"), e);
}