Bil*_*ill 2 javascript google-authentication reactjs
我试图在用户时钟登录时点击一下出现,下面的代码在页面加载后立即运行时工作得很好,但如果我尝试让它在单击时运行,则会收到我不知道的错误suppressed_by_user错误没有运行广告拦截插件,我不知道这suppressed_by_user意味着什么?
这里的文档详细介绍了该错误,但没有解释导致该错误的原因或如何修复该错误。
\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>\nRun Code Online (Sandbox Code Playgroud)\n
这意味着用户之前已经手动关闭了“一键”提示,从而触发了“冷却”功能(如文档所述: https: //developers.google.com/identity/one-tap/web/guides/features#exponential_cooldown)。
冷却期间,一键提示被抑制。
| 归档时间: |
|
| 查看次数: |
3456 次 |
| 最近记录: |