原生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

