Google Identity Services bermigrasi ke FedCM API. Ikuti panduan migrasi untuk meninjau kemungkinan perubahan dan menghindari dampak negatif bagi login pengguna ke situs Anda.
Menangani respons kredensial dengan fungsi JavaScript
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Menangani respons kredensial
Anda dapat menetapkan fungsi JavaScript di atribut data-callback untuk menangani
respons kredensial yang ditampilkan. Lihat cuplikan kode berikut:
<divid="g_id_onload"data-client_id="YOUR_GOOGLE_CLIENT_ID"data-callback="handleCredentialResponse">
</div>
<script>
functionhandleCredentialResponse(response){// decodeJwtResponse() is a custom function defined by you// to decode the credential response.constresponsePayload=decodeJwtResponse(response.credential);console.log("ID: "+responsePayload.sub);console.log('Full Name: '+responsePayload.name);console.log('Given Name: '+responsePayload.given_name);console.log('Family Name: '+responsePayload.family_name);console.log("Image URL: "+responsePayload.picture);console.log("Email: "+responsePayload.email);}
</script>
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-11-08 UTC."],[],[]]