[英]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.