public void authenticate ( HttpURLConnection httpConn , String url ) { String authorization = null ; if ( hasAccessToken ( ) && isOperationOauth ( url ) ) { logger . debug ( "Using OAuth token to authenticate" ) ; authorization = getAccessTokenType ( ) + " " + getAccessToken ( ) ; } else if ( hasApiKey ( ) ) { logger . debug ( "Using API Key to authenticate" ) ; String apiKey = getApiKey ( ) + ":" ; authorization = "Basic " + DatatypeConverter . printBase64Binary ( apiKey . getBytes ( ) ) . trim ( ) ; } if ( authorization != null ) { logger . debug ( "Authorization: " + authorization ) ; httpConn . setRequestProperty ( "authorization" , authorization ) ; } }
Authorizes the HTTP connection using this instance s credentials .