[英]Getting 401 unauthorized error in retrofit?
错误401 unauthorized
意味着由于凭据无效而拒绝请求。 我正在使用改装请求https
URL并在执行curl https://external:userName@api-staging.xyz.com/user/get
获得401 unauthorized
curl https://external:userName@api-staging.xyz.com/user/get
它对我来说非常有效(获得预期的输出)。
我的application
的Retrofit
实现没有任何问题,因为其他调用工作正常。 这是我无法将此类URL传递给retrofit.setEndpoint
吗?
Retrofit可能不支持在URL中输入用户名和密码(出于安全原因)。 这种身份验证称为基本身份验证,您也可以在HTTP头中传递这些参数。
这是一篇关于如何在Retrofit中完成的文章: https : //futurestud.io/blog/android-basic-authentication-with-retrofit/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.