Sign up with Apple – Firebase – Angular Web JavaScript

huangapple go评论52阅读模式
英文:

Sign up wit Apple - Firebase - Angular Web JavaScript

问题

I'm trying to add the Apple Authentication offered by Firebase.
我正在尝试添加Firebase提供的苹果身份验证。

I've created a Apple Developer account and have made the necessary actions on their end.
我已经创建了Apple开发者帐户并在他们的端采取了必要的操作。

Below is the code that I use when the apple login button from my Web app is clicked:
以下是我在Web应用程序中点击苹果登录按钮时使用的代码:

It follows this example: https://firebase.google.com/docs/auth/web/apple?authuser=0&hl=en#web-version-9
它遵循此示例:https://firebase.google.com/docs/auth/web/apple?authuser=0&hl=en#web-version-9

logInApple() {
const provider = new OAuthProvider('apple.com');
provider.addScope('email');
provider.addScope('name');

const auth = getAuth();
signInWithPopup(auth, provider)
  .then((result) => {
    debugger;

    // The signed-in user info.
    const user = result.user;

    // Apple credential
    const credential = OAuthProvider.credentialFromResult(result);
    const accessToken = credential.accessToken;
    const idToken = credential.idToken;

  })
  .catch((error) => {
    debugger;
    // Handle Errors here.
    const errorCode = error.code;
    const errorMessage = error.message;
    // The email of the user's account used.
    const email = error.customData.email;
    // The credential that was used.
    const credential = OAuthProvider.credentialFromError(error);

    // ...
  });
  
} // logIn()

The catch error handler is triggered with the following message:
catch错误处理程序触发以下消息:

Firebase: The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section. (auth/operation-not-allowed).
Firebase:此Firebase项目中禁用了指定的登录提供程序。在Auth部分的登录方法选项卡下,在Firebase控制台中启用它(auth/operation-not-allowed)。

But the Apple provider is activated. Picture above.
但苹果提供程序已激活。如上图所示。

I've even tried to enable/disable/remove/add it again and doesn't work.
我甚至尝试过再次启用/禁用/删除/添加它,但没有效果。

Before this error, the previous error was:
在出现这个错误之前,之前的错误是:

Firebase: Unable to establish a connection with the popup. It may have been blocked by the browser.
Firebase:无法建立与弹出窗口的连接。可能被浏览器阻止了。

I've also tried to remove/modify the field in Firebase Authentication Provides > Apple > Services ID (not required for Apple) but nothing happens.
我还尝试过在Firebase身份验证提供程序>苹果>服务ID中删除/修改字段(不需要为苹果),但没有任何变化。

英文:

I'm trying to add the Apple Authentication offered by Firebase.

I've created a Apple Developer account and have made the necessary actions on their end.

Below is the code that I use when the apple login button from my Web app is clicked:
It follows this example: https://firebase.google.com/docs/auth/web/apple?authuser=0&hl=en#web-version-9

    logInApple() {
        const provider = new OAuthProvider('apple.com');
        provider.addScope('email');
        provider.addScope('name');

        const auth = getAuth();
        signInWithPopup(auth, provider)
          .then((result) => {
            debugger;

            // The signed-in user info.
            const user = result.user;

            // Apple credential
            const credential = OAuthProvider.credentialFromResult(result);
            const accessToken = credential.accessToken;
            const idToken = credential.idToken;

          })
          .catch((error) => {
            debugger;
            // Handle Errors here.
            const errorCode = error.code;
            const errorMessage = error.message;
            // The email of the user's account used.
            const email = error.customData.email;
            // The credential that was used.
            const credential = OAuthProvider.credentialFromError(error);

            // ...
          });
          
        } // logIn()

Sign up with Apple – Firebase – Angular Web JavaScript

The catch error handler is triggered with the following message:

Firebase: The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section. (auth/operation-not-allowed). 

But the Apple provider is activated. Picture above.
I've even tried to enable/disable/remove/add it again and doesn't work.

Before this error, the previous error was:

Firebase: Unable to establish a connection with the popup. It may have been blocked by the browser.

I've also tried to remove/modify the field in Firebase Authentication Provides > Apple > Services ID (not required for Apple) but nothing happens.

答案1

得分: 2

我找到了问题。
需要在Firebase上配置苹果登录。
所有字段都是必填的。

这让人感到困惑,因为:

  1. 它说:“服务 ID (不需要苹果)”。
  2. 您必须点击“OAuth 代码流配置 (可选)”以打开选项。
英文:

I found the issue.
The configuration of Apple sign in on Firebase was required.
All of the fields were required.

It was confusing because:

  1. it says: "Services ID (not required for Apple)"
  2. You have to click on "OAuth code flow configuration (optional)" to open the options

Sign up with Apple – Firebase – Angular Web JavaScript

huangapple
  • 本文由 发表于 2023年2月7日 01:56:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75364909.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定