Authentication failure via API and Compass

Does your password has any special characters?
If yes you have to escape those characters
If it is working in shell means you might have enclosed password in quotes