Android 使用 apple 和 firebase flutter 登录

Android Sign in with apple and firebase flutter

我正在使用 sign_in_with_apple 并且我已经为 ios 登录,但是 android 组件不工作。

我已经查看了文档和提出这个问题的问题,但没有明确的答案。 https://github.com/aboutyou/dart_packages/tree/master/packages/sign_in_with_apple

我被困在这个插件的文档部分:

On the Sign in with Apple callback on your sever (specified in WebAuthenticationOptions.redirectUri), redirect safely back to your Android app using the following URL:

intent://callback?${PARAMETERS_FROM_CALLBACK_ BODY}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end

The PARAMETERS FROM CALLBACK BODY should be filled with the urlencoded body you receive on the endpoint from Apple's server, and the package parameter should be changed to match your app's package identifier (as published on the Google Play Store). Leave the callback path and signinwithapple scheme untouched.

Furthermore, when handling the incoming credentials on the client, make sure to only overwrite the current (guest) session of the user once your own server have validated the incoming code parameter, such that your app is not susceptible to malicious incoming links (e.g. logging out the current user).

这部分内容是:The PARAMETERS FROM CALLBACK BODY 应该用您在端点上从 Apple 服务器收到的 urlencoded 正文填充。我不确定如何获得它并正确格式化 redirectURL 的 PARAMATERS_FROM_CALLBACK_BODY 部分以使它适用于 Android.

我有完全相同的问题,实际上我昨天在他们的回购中打开了一个 issue

我不确定您是否正在尝试设置自己的后端服务器以进行回调,但为了回答您的问题,您有问题要理解的部分仅适用于需要实现其功能的人拥有 API 回电。

我确实通过以下步骤让 Android 的 Apple 登录正常工作(通过网络浏览器身份验证):

注意因为你已经iOS部分工作了,所以我假设你已经完成了基本配置.

  1. 根据他们的 document 设置 glitch.com 服务,这部分很容易理解。

  2. 然后你想实现你的 signInWithApple 调用如下 reference 注意:SERVER_AS_PER_THE_DOCS 需要根据你的故障服务进行更新。

    Future<FirebaseUser> signInWithApple() async {
    var redirectURL = "https://SERVER_AS_PER_THE_DOCS.glitch.me/callbacks/sign_in_with_apple";
    var clientID = "AS_PER_THE_DOCS";
    final appleIdCredential = await SignInWithApple.getAppleIDCredential(
        scopes: [
          AppleIDAuthorizationScopes.email,
          AppleIDAuthorizationScopes.fullName,
        ],
        webAuthenticationOptions: WebAuthenticationOptions(
            clientId: clientID,
            redirectUri: Uri.parse(
                redirectURL)));
    final oAuthProvider = OAuthProvider(providerId: 'apple.com');
    final credential = oAuthProvider.getCredential(
      idToken: appleIdCredential.identityToken,
      accessToken: appleIdCredential.authorizationCode,
    );
    final authResult =
        await SignInUtil.firebaseAuth.signInWithCredential(credential);
    return authResult.user; }