跳过的时刻:当“一键式登录”提示因自动取消、手动取消而关闭,或者 Google 未能签发凭据(例如,所选会话已退出 Google)时,就会发生这种情况。
在这种情况下,我们建议您继续尝试其他身份提供程序(如果有)。
关闭时刻:当 Google 成功检索到凭据,或用户想要停止凭据检索流程时,就会发生这种情况。例如,当用户开始在登录对话框中输入用户名和密码时,您可以调用 google.accounts.id.cancel() 方法来关闭一键式登录提示并触发关闭时刻。
以下代码示例实现了跳过的时刻:
<script>
function continueWithNextIdp(notification) {
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
// try Next provider if One Tap is not displayed or skipped
}
}
</script>
...
<div id="g_id_onload"
data-client_id="YOUR_GOOGLE_CLIENT_ID"
data-login_uri="https://your.domain/your_login_endpoint"
data-moment_callback="continueWithNextIdp"
</div>
[null,null,["最后更新时间 (UTC):2024-11-21。"],[[["Developers can customize the default login flow to better suit their application's needs."],["To determine whether to utilize additional identity providers, developers can monitor the prompt UI status using a callback function."],["The prompt UI status includes key moments like display, skipped, and dismissed, enabling developers to manage user login efficiently."],["When Google successfully retrieves credentials or the user stops the process (\"dismissed moment\"), avoid using other identity providers."],["The provided code example demonstrates how to handle the \"skipped moment\" and proceed with alternative login options."]]],[]]