英文:
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()
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上配置苹果登录。
所有字段都是必填的。
这让人感到困惑,因为:
- 它说:“服务 ID (不需要苹果)”。
- 您必须点击“OAuth 代码流配置 (可选)”以打开选项。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论