簡體   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