Refactor URI compaction function
Use basic auth only for API requests