factored base64Encode: utility method. added basic http auth header