Google Identity Services در حال انتقال به APIهای FedCM است. راهنمای مهاجرت را دنبال کنید تا تغییرات احتمالی را بررسی کنید و از تأثیرات منفی ورود کاربر به وب سایت خود جلوگیری کنید.
پاسخ های اعتبارنامه را با توابع جاوا اسکریپت مدیریت کنید
پاسخ اعتبارنامه را مدیریت کنید
می توانید یک تابع جاوا اسکریپت را در ویژگی data-callback تنظیم کنید تا پاسخ اعتبارنامه برگشتی را مدیریت کند. قطعه کد زیر را ببینید:
<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>
تاریخ آخرین بهروزرسانی 2024-11-19 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-11-19 بهوقت ساعت هماهنگ جهانی."],[[["Google Identity Services allows customization of the default login flow to fit specific needs."],["Customization can be achieved using JavaScript in conjunction with the HTML API, particularly by handling the credential response with a callback function."],["Developers need to decode the JWT credential and verify the Google ID token on the server side for security."],["The `data-callback` attribute enables custom handling of user credentials, while avoiding simultaneous use with the `data-login_uri` attribute."]]],[]]