Sign up with Apple – Firebase – Angular Web JavaScript

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

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');

  1. const auth = getAuth();
  2. signInWithPopup(auth, provider)
  3. .then((result) => {
  4. debugger;
  5. // The signed-in user info.
  6. const user = result.user;
  7. // Apple credential
  8. const credential = OAuthProvider.credentialFromResult(result);
  9. const accessToken = credential.accessToken;
  10. const idToken = credential.idToken;
  11. })
  12. .catch((error) => {
  13. debugger;
  14. // Handle Errors here.
  15. const errorCode = error.code;
  16. const errorMessage = error.message;
  17. // The email of the user's account used.
  18. const email = error.customData.email;
  19. // The credential that was used.
  20. const credential = OAuthProvider.credentialFromError(error);
  21. // ...
  22. });
  23. } // 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

  1. logInApple() {
  2. const provider = new OAuthProvider('apple.com');
  3. provider.addScope('email');
  4. provider.addScope('name');
  5. const auth = getAuth();
  6. signInWithPopup(auth, provider)
  7. .then((result) => {
  8. debugger;
  9. // The signed-in user info.
  10. const user = result.user;
  11. // Apple credential
  12. const credential = OAuthProvider.credentialFromResult(result);
  13. const accessToken = credential.accessToken;
  14. const idToken = credential.idToken;
  15. })
  16. .catch((error) => {
  17. debugger;
  18. // Handle Errors here.
  19. const errorCode = error.code;
  20. const errorMessage = error.message;
  21. // The email of the user's account used.
  22. const email = error.customData.email;
  23. // The credential that was used.
  24. const credential = OAuthProvider.credentialFromError(error);
  25. // ...
  26. });
  27. } // logIn()

Sign up with Apple – Firebase – Angular Web JavaScript

The catch error handler is triggered with the following message:

  1. 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:

  1. 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:

确定