Reputation:
Error 401 unauthorized
means request is denied due to invalid credentials. I am making request to https
URL using retrofit and getting 401 unauthorized
while doing curl https://external:[email protected]/user/get
it works perfectly for me (getting expected output).
There is nothing wrong with the Retrofit
implementation in my application
because other calls is working fine. Is that something that I cannot pass such URL to retrofit.setEndpoint
?
Upvotes: 4
Views: 9746
Reputation: 16910
It is possible that Retrofit does not support putting the username and password in the URL (due to security reasons). This kind of authentication is called Basic Authentication, and you can pass these parameters in an HTTP header as well.
Here's an article about how that can be done in Retrofit: https://futurestud.io/blog/android-basic-authentication-with-retrofit/
Upvotes: 5