我正在使用 Firebase 为 MS Powerpoint 插件开发身份验证。为了添加 Google 身份验证,我创建了一个打开对话框的按钮:
`function openGoogleAuthDialog() {
Office.context.ui.displayDialogAsync(hostURLofDialogComponent,
{ width: 50, height: 50 }, (result) => {
if (result.status === Office.AsyncResultStatus.Succeeded) {
dialog = result.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
} else {
console.log("Unable to open dialog box");
}
});
}`
对话框成功打开。在 Dialog 组件中,我有另一个应该重定向到 google 的按钮以及一个应该将身份验证结果发送回父级的 useEffect。
`export function AuthDialog() {
const authFirebase = getAuth(firebaseApp);
const handleAuth = () => {
const provider = new GoogleAuthProvider();
signInWithRedirect(authFirebase, provider);
};
useEffect(() => {
getRedirectResult(authFirebase).then((result) => {
Office.context.ui.messageParent(JSON.stringify(result));
});
}, []);
return <button onClick={handleAuth}>Authenticate With Google</button>;
}`
问题是,如果我单击按钮,它将离开页面,并且似乎会重定向,但然后停止并返回到对话框组件,而不向我显示谷歌登录界面。
我在谷歌浏览器和勇敢浏览器中尝试了此功能,它按预期显示了谷歌登录界面。由于 MS Office 插件在后台使用 Safari,并且该功能在 Safari 浏览器中以同样的错误方式运行,因此我可以想象这是 Safari 的问题。有人遇到过类似的问题吗?非常感谢您的帮助!
你能解决这个问题吗?这在我这边工作正常,但突然停止工作,我在 getRedirectResult 上得到一个空用户(仅在我的 Mac 上。Windows 机器工作正常。这似乎是 safari 的问题)。