【问题标题】:Is it possible to use Digest Auth with Fetch in React Native?是否可以在 React Native 中使用 Digest Auth 和 Fetch?
【发布时间】:2018-01-31 15:38:49
【问题描述】:

我想知道是否可以在 React Native 中将摘要身份验证作为标头与 Fetch 一起使用?或者,还有其他选择吗?我尝试了以下方法:

  const headers = new Headers();
  headers.append("Authorization", "Digest " + ("username:password"));
  return fetch(`url`,{
  headers: {
  headers,
  'Accept': 'application/json',
            'Content-Type': 'application/json'
 }
 })
.then((response) => response.json())
.then((responseJson) => {
  console.log("checked if on local server response")

  return responseJson;
})
.catch((error) => {
  console.log('checked if on local server response error')
});

【问题讨论】:

    标签: react-native fetch-api digest-authentication


    【解决方案1】:

    有一个适用于 RN 的外部模块: https://github.com/besing/digest-auth-request-rn

    这对我来说在 Android 上运行良好,但我必须进行一些本地更改才能让它在 iOS 上运行。我将提交这些修改以供您使用。

    【讨论】:

    • 我会从中受益匪浅 :) 所以如果你能发布你的代码那就更好了
    猜你喜欢
    • 1970-01-01
    • 2020-05-04
    • 2023-03-04
    • 2022-07-29
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 2018-11-28
    • 2020-06-08
    相关资源
    最近更新 更多