使用 Google One Tap 时,“suppressed_by_user”是什么意思?

Bil*_*ill 2 javascript google-authentication reactjs

我试图在用户时钟登录时点击一下出现,下面的代码在页面加载后立即运行时工作得很好,但如果我尝试让它在单击时运行,则会收到我不知道的错误suppressed_by_user错误没有运行广告拦截插件,我不知道这suppressed_by_user意味着什么?

\n\n

这里的文档详细介绍了该错误,但没有解释导致该错误的原因或如何修复该错误。

\n\n
<script src="https://accounts.google.com/gsi/client"></script>\n... \n  const signin = () => {\n    const handleCredentialResponse = (response: any) => {\n      const credential = response.credential;\n      const getDetails = async () => {\n        const params = new window.URLSearchParams({ credential });\n        const url = `${process.env.REACT_APP_API_BASE_URL}/google?${params}`;\n        const response = await fetch(url, { method: "GET" });\n        const data = await response.json();\n        setLoggedIn(true);\n        setState({ ...state, participant: data.participant });\n      };\n      getDetails();\n    };\n    if (state && state.participant && state.participant.id) {\n      setLoggedIn(true);\n    } else {\n      const client_id = process.env.REACT_APP_GOOGLE_CLIENT_ID;\n      const callback = handleCredentialResponse;\n      const auto_select = false;\n      const cancel_on_tap_outside = false;\n      google.accounts.id.initialize({ client_id, callback, auto_select, cancel_on_tap_outside });\n      google.accounts.id.prompt((notification: any) => {\n        console.log(notification); // rl\xc2\xa0{g: "display", h: false, j: "suppressed_by_user"}\n        console.log(notification.getNotDisplayedReason()); // suppressed_by_user\n      });\n    }\n  };\n...\n<div className="center--main-join" onClick={signin}>Sign in or Join</div>\n
Run Code Online (Sandbox Code Playgroud)\n

Gui*_*bin 6

这意味着用户之前已经手动关闭了“一键”提示,从而触发了“冷却”功能(如文档所述: https: //developers.google.com/identity/one-tap/web/guides/features#exponential_cooldown)。

冷却期间,一键提示被抑制。

  • 因此,如果用户不小心不考虑后果(并且通常用户不知道会发生什么)手动关闭一键提示,他实际上会被禁止登录,直到冷却期结束为止?这看起来非常严厉,并且可能会破坏“一键”的交易,还是我误解了这个“功能”? (5认同)