繁体   English   中英

在改造中获得401未经授权的错误?

[英]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它对我来说非常有效(获得预期的输出)。

我的applicationRetrofit实现没有任何问题,因为其他调用工作正常。 这是我无法将此类URL传递给retrofit.setEndpoint吗?

Retrofit可能不支持在URL中输入用户名和密码(出于安全原因)。 这种身份验证称为基本身份验证,您也可以在HTTP头中传递这些参数。

这是一篇关于如何在Retrofit中完成的文章: https//futurestud.io/blog/android-basic-authentication-with-retrofit/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM