You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

原生App通过Supabase实现Sign in with Apple登录失败求助

问题

我正尝试通过Supabase,使用gotrue-swift SDK为原生App实现Sign in with Apple登录功能。参考示例代码开发,已配置Sign in with Apple能力,且在Supabase控制台启用了该登录提供商,但登录时出现错误:

GoTrue.GoTrueError.api
  ▿ api: GoTrue.GoTrueError.APIError
    - message: nil
    ▿ msg: Optional("Provider (issuer \"https://appleid.apple.com\") is not enabled")
      - some: "Provider (issuer \"https://appleid.apple.com\") is not enabled"
    ▿ code: Optional(400)
      - some: 400
    - error: nil
    - errorDescription: nil

核心代码如下:

...
SignInWithAppleButton { request in
            let nonce = randomString()
            self.nonce = nonce
            request.nonce = sha256(nonce)
            request.requestedScopes = [.email, .fullName]
          } onCompletion: { result in
            Task {
              do {
                guard let credential = try result.get().credential as? ASAuthorizationAppleIDCredential
                else {
                  return
                }

                guard let idToken = credential.identityToken
                  .flatMap({ String(data: $0, encoding: .utf8) })
                else {
                  return
                }

                  try await accountProvider.userAcccount.gtClient.signInWithIdToken(
                  credentials: .init(
                    provider: .apple,
                    idToken: idToken,
                    nonce: nonce
                  )
                )
              } catch {
                dump(error)
              }
            }
          }

已检查Apple ID设置,确认App已启用Sign in with Apple,请问遗漏了什么配置?

解决思路
  • 确认Supabase控制台中Apple登录的**服务ID(Service ID)**配置正确:
    需在Apple开发者后台创建对应App的Service ID,启用Sign in with Apple,并将该Service ID填写到Supabase控制台的Apple登录配置项中,同时确保Service ID的回调URL设置为https://<你的Supabase项目ID>.supabase.co/auth/v1/callback。

  • 检查Supabase项目的站点URL配置:
    在Supabase控制台的「Authentication」→「Settings」中,确认「Site URL」已正确设置(需与Apple开发者后台中Service ID的回调URL匹配的域名前缀,比如https://<你的Supabase项目ID>.supabase.co)。

  • 验证Apple开发者后台的Sign in with Apple配置:
    除了App本身启用该能力,还要确保对应的Service ID已关联正确的App ID,且在「Sign in with Apple」的配置中,已添加Supabase的回调URL到「Return URLs」列表。

  • 检查gotrue-swift SDK的初始化参数:
    确认初始化GoTrueClient时使用的URL和anon key是正确的Supabase项目对应值,避免因项目环境(比如测试/生产)混淆导致的配置不匹配。

  • 清除缓存并重新测试:
    有时候Supabase的配置变更需要几分钟生效,可尝试清除App缓存、重启App后重新测试登录流程。

内容的提问来源于stack exchange,提问作者Jobie J

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 18:07:20