บริการ Google Identity กำลังย้ายข้อมูลไปยัง FedCM API ทำตามคำแนะนำในการย้ายข้อมูลเพื่อตรวจสอบการเปลี่ยนแปลงที่อาจเกิดขึ้นและหลีกเลี่ยงผลกระทบในแง่ลบที่ผู้ใช้ลงชื่อเข้าใช้เว็บไซต์ของคุณ
<script>
window.onload = function () {
google.accounts.id.initialize({
client_id: 'YOUR_GOOGLE_CLIENT_ID',
callback: handleCredentialResponse
});
google.accounts.id.prompt((notification) => {
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
// try next provider if OneTap is not displayed or skipped
}
});
}
</script>
โค้ดตัวอย่างด้านล่างแสดงวิธีแสดงผลทั้งปุ่มแตะเดียวและปุ่มลงชื่อเข้าใช้ด้วย Google ใน JavaScript
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2024-11-23 UTC"],[[["Developers can customize the default login flow using JavaScript to better suit their specific needs."],["You can trigger the One Tap prompt or display the Sign in with Google button programmatically using JavaScript."],["The `initialize()` and `prompt()` methods are key to configuring and displaying the One Tap prompt in your web application."],["To receive updates on the prompt's status, such as if it's not displayed or skipped by the user, a callback function can be provided to the `prompt()` method."],["JavaScript allows for rendering both the One Tap prompt and the Sign in with Google button, offering users flexible login options."]]],[]]