firebase - Firebase 和 LinkedIn Auth 集成未知路由
问题描述
我一直在研究这个代码库作为如何使用 Firebase 后端对我的项目实施 LinkedIn 授权的示例。我感到困惑的一件事是这些行:
var code = getURLParameter("code");
var state = getURLParameter("state");
var error = getURLParameter("error");
if (error) {
document.body.innerText = "Error back from the LinkedIn auth page: " + error;
} else if (!code) {
// Start the auth flow.
window.location.href = "/redirect";
}
在window.location.href = '/redirect'
,我相信它是为了调用称为“重定向”的云函数。在我的代码库中,它只是去一个未知的路线并触发我的后备。我对这行代码的目的有误吗?有谁知道它没有触发云功能的任何可能原因(控制台说 0 次调用)?我应该查看哪些其他信息来尝试调试它?
解决方案
为了提供更全面的答案:
您提供的示例依赖于 Firebase.json 文件。当(且仅当)您的应用程序由 Firebase 托管托管时,此文件提供配置(请参阅文档)。
如果您希望在其他地方托管您的应用程序,则需要确保您的/redirect
路径指向 Firebase 函数 URL 本身(可能类似于https://us-central1-project-name.cloudfunctions.net/redirect)。在授权流程中,示例 repo 中的 LinkedIn 模块将重定向到默认或配置的回调 url。
推荐阅读
- amazon-ec2 - AWS EC2:如何使用命令行将某些 IP 列入白名单?
- c - 将数组结构作为函数指针传递并初始化
- java - 在 Weblogic 中访问另一个应用程序的 Jar 文件
- android - 有选择地停止推送通知侦听器或为 Expo Push Notifications 切换 _displayInForeground
- javascript - 如何自定义谷歌浏览器标签悬停卡
- elasticsearch - 如何修复关键字字段的ElasticSearch“默认情况下在文本字段上禁用字段数据”
- c# - 升级目标版本和最低版本后 UWP 应用程序未调试
- c# - 为什么没有任何东西传递给我的重载函数?
- react-native - 如何在 React Native 中读取通知?
- swiftui - SwiftUI 中的 Swift @propertyWrapper