Realm SyncUser.authenticate 使用 Google 的 clientID 和 Facebook 失败

2023-12-27

我使用 Google 进行身份验证,如下所示:

let credential = Credential.google(token: "<SOME-HASH-HERE>.apps.googleusercontent.com")
SyncUser.authenticate(with: credential, server: serverURL, timeout: 60) { [weak self] user, error in
    guard nil == error else {
        print("error while authenticating: \(error!)")
        return
    }
    …
}

它给出了错误 400。经过一些调试后,我发现了有关该问题的更多信息,但仍然不确定出了什么问题。所以响应看起来像这样:

{
  "invalid_params":[
    {
      "name":"provider",
      "reason":"Unknown provider!"
    }
  ],
  "status":400,
  "type":"https://realm.io/docs/object-server/problems/invalid-parameters",
  "title":"Your request parameters did not validate!",
  "code":601
}

这是请求正文:

{
  "provider":"google",
  "app_id":"com.blabla.bla-bla-bla",
  "data":"<SOME-HASH-HERE>.apps.googleusercontent.com"
}

我从官方文档的示例中获取了授权代码,并且我正在使用最新的 Realm 框架。

我还使用 Facebook 检查了身份验证,但它给出了同样的错误。

我检查了服务器上的configuration.yml文件,并取消了注释google and facebook,输入所需的详细信息,然后重新启动系统。没有帮助。

有人遇到同样的问题吗?

PS:configuration.yml(仅部分providers):

# Realm Object Server Configuration
#
# For each possible setting, the commented out values are the default values
# unless another default is mentioned explicitly.
#
# Paths specified in this file can be either absolute or relative.
# Relative paths are relative to the current working directory.

  providers:
    ## Providers of authentication tokens. Each provider has a configuration
    ## object associated with it. If a provider is included here and its
    ## configuration is valid, it will be enabled.

    ## Possible providers: cloudkit, debug, facebook, realm, password
    ## Providers 'realm' and 'password' are always enabled:
    ## - The 'realm' provider is used to derive access tokens from a refresh token.
    ## - The 'password' provider is required for the dashboard to work. It supports
    ##   authentication through username/password and uses a PBKDF2 implementation.

    ## This enables authentication via a Google Sign-In access token for a
    ## specific app.
    google:
      ## The client ID as retrieved when setting up the app in the Google
      ## Developer Console.
      clientId: '<SOME-HASH-HERE>.apps.googleusercontent.com'

    ## This enables authentication via a Facebook access token for a specific app.
    ## This provider needs no configuration (uncommenting the next line enables it).
    facebook: {}

在我对该文件进行更改后,我调用了

sudo service realm-object-server restart

为了确保我也重新启动系统。


不幸的是,示例中有一个错误configuration.yml我怀疑您正在访问领域对象服务器附带的文件。这providers:配置文件中的部分应该位于auth:部分(而不是在network:它位于交付文件中的部分)。解决方法是简单地将相关提供者配置移至以下位置auth: key.

我们已准备好针对此错误的修复程序,该修复程序将成为 Realm Object Server 下一版本的一部分。

这是显示完整内容的示例片段auth:修复部分:

# Realm Object Server Configuration
#
# For each possible setting, the commented out values are the default values
# unless another default is mentioned explicitly.
#
# Paths specified in this file can be either absolute or relative.
# Relative paths are relative to the current working directory.

auth:
  ## The path to the public and private keys (in PEM format) that will be used
  ## to validate identity tokens sent by clients.
  ## These configuration options are MANDATORY.
  public_key_path: /etc/realm/token-signature.pub
  private_key_path: /etc/realm/token-signature.key

  providers:
    ## Providers of authentication tokens. Each provider has a configuration
    ## object associated with it. If a provider is included here and its
    ## configuration is valid, it will be enabled.

    ## Possible providers: cloudkit, debug, facebook, realm, password
    ## Providers 'realm' and 'password' are always enabled:
    ## - The 'realm' provider is used to derive access tokens from a refresh token.
    ## - The 'password' provider is required for the dashboard to work. It supports
    ##   authentication through username/password and uses a PBKDF2 implementation.

    ## This enables authentication via a Google Sign-In access token for a
    ## specific app.
    google:
      ## The client ID as retrieved when setting up the app in the Google
      ## Developer Console.
      clientId: '<SOME-HASH-HERE>.apps.googleusercontent.com'

    ## This enables authentication via a Facebook access token for a specific app.
    ## This provider needs no configuration (uncommenting the next line enables it).
    facebook: {}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Realm SyncUser.authenticate 使用 Google 的 clientID 和 Facebook 失败 的相关文章

  • Realm Swift:如何捕获 RLMException?

    我以为我做得正确 let realm try Realm do try realm write realm add myObject catch print something went wrong 但我仍然遇到崩溃而不是打印语句 我对避免
  • 如何向导航栏添加阴影而不是默认边框

    我想替换默认边框UINavigationBar与阴影 有什么办法可以实现这一点吗 我尝试使用与向 UIView 添加阴影相同的方法 但它增加了导航栏的高度 尝试这个 self navigationController navigationB
  • java.net.ConnectException:无法连接到/127.0.0.1:9080领域对象服务器

    我在看到网站中的文档后刚刚安装了领域对象服务器 我创建了一个登录页面 android 并根据网站使用了同步用户设置 但我在创建时的 asynctask 显示了上述错误 这是我的代码 public class RealAsyncTask ex
  • 完全离线工作的领域(从不在线)

    我试图了解 mongoDB 的每个元素是如何工作的 但我真的很困惑如何处理离线 即将 https realm io https realm io 我读到了这个 Realm 移动数据库是 Core Data 和 SQLite 的开源 开发人员
  • 没有“+=”候选者产生预期的上下文结果类型“Int”[重复]

    这个问题在这里已经有答案了 我一直在更新 Swift 3 的 Swift 代码 真的很兴奋 到目前为止一切顺利 但我确实遇到了一些我似乎无法更新的代码 我知道我错过了一些非常简单的东西 但我就是看不出是什么 这是我在 Swift 2 2 中
  • 领域未获取数据

    我在使用领域时遇到问题 findAll 和 findAllAsync 不会从领域返回任何数据 我正在像这样从主线程更新领域对象 public void updatePhoto final int ticketID realm beginTr
  • 非转义参数的闭包使用 - Swift 3 问题

    我知道 Swift 3 中的更改 其中 nonescaping 是闭包的默认行为 我已成功更改了有关更改的大部分代码 但我的代码的一部分无法摆脱闭包使用非转义参数可能会导致其转义编译错误 我尝试将 escaping 添加到 updateHa
  • 尝试以紧凑模式访问 UITextView 时 iMessage 扩展程序崩溃

    下面是我在 iMessage 应用程序中的完整代码 class MessagesViewController MSMessagesAppViewController IBOutlet weak var messageView UITextV
  • Swift:多个本地通知,但只显示最新的

    我想在一天中的某些时间显示本地通知 并且我应该只能在通知中心看到 一个 最新通知 然而我的问题是 1 如果我将本地通知设置为不同的标识符 我会收到多个通知 这是预期的 但不是我想要的 2 如果我有一个标识符并将其设置为所有时间 我只会在我设
  • 来自 URL 的 YouTube 视频 ID - Swift3

    基本上我有一个 Youtube URL 作为字符串 我想从该 URL 中提取视频 ID 我在 Objective C 中找到了一些代码 如下所示 NSError error NULL NSRegularExpression regex NS
  • Linux 中的 Swift arc4random_uniform(max)

    我在 Ubuntu 中使用 Swift 收到一条错误消息 指出 arc4random 是一个无法解析的标识符 有关此已知错误的更多信息here https bugs swift org browse SR 685 基本上 该功能仅存在于 B
  • 领域对象返回 nil (Swift)

    我有一个自定义多边形对象 因此我可以将地图叠加保存到领域 我能够成功创建这个对象 但是当我想检索 var 多边形对象时 它返回 nil 当我打印多边形对象时 它可以很好地打印出所有数据 这是打印内容的示例 CustomPolygon nam
  • 无法在 Swift 3 / iOS 10 中触发 continueUserActivity

    注意 我已经弄清楚了大部分内容 请参阅最后的更新 还是有些迷茫 我正在尝试在 Swift 3 下的 Xc8b6 中实现 NSUserActivity 处理 但处理程序协议方法的方法签名遇到问题 在当前的文档中 该方法据说是 func app
  • 使用多个 DispatchQueue.main.async 查看冻结

    视图冻结而数据是获取并显示 以我的理解fetchBoard and initUserInfo 不要并行执行 因为视图仅在以下情况下加载fetchBoard 加载板 我担心如果使用DispatchQueue main async多次冻结视图
  • 当前位置在 Google 地图中不起作用

    我在 swift 3 中集成了谷歌地图 当地图屏幕出现而不显示当前位置时 我在 plist 文件中添加了两个键 并设置了 CLLocationManager delegate 和 requestAlwaysAuthorization cla
  • 无法转换“String”类型的值?预期参数类型“URL”

    我正在尝试从主包中的文件加载数据 当我使用这段代码时 let path Bundle main path forResource abc ofType txt let dataTwo try Data contentsOf path err
  • 失败:错误域=NSURLErrorDomain代码=-1004“无法连接到服务器。”

    首先 我想列出我已阅读并尝试实现答案的帖子 避免重复 iOS 9 和 iOS 10 中的应用程序传输安全问题 https stackoverflow com questions 40280936 app transport security
  • Swift 3 中数组的 indexOf(_:) 方法的替换

    在我的项目 用 Swift 3 编写 中 我想使用从数组中检索元素的索引indexOf 方法 存在于 Swift 2 2 中 但我找不到任何替代方法 Swift 3 中是否有任何好的替代方法或类似的方法 Update 我忘记提及我想在自定义
  • (AD) ldap 领域中的组成员资格

    我在 java ee 企业应用程序中使用 JAAS 框架进行身份验证和授权过程 我使用 GlassFish 作为应用程序服务器 我的领域配置如下所示
  • 领域:结果 和列表

    是否可以转换Results

随机推荐