با مجموعهها، منظم بمانید
ذخیره و دستهبندی محتوا براساس اولویتهای شما.
پس از اینکه سرویس گیرنده Google Sign-In مقداردهی اولیه شد، میتوانید کنترلکنندههایی را ضمیمه کنید که ویژگیها و روشهای مختلف کلاینت را برای تعیین وضعیت جلسه کاربر بررسی میکنند. میتوانید از اطلاعات بازگردانده شده توسط شی مشتری برای همگامسازی تجربه کاربری سایت خود در چندین برگه و دستگاه برای کاربر خود استفاده کنید.
کد زیر استفاده از روش کلاینت 2.0 attachClickHandler برای ایجاد یک فراخوانی نشان میدهد که یا بهطور بیصدا ورود کاربر را به پایان میرساند، یا از کاربر میخواهد بر اساس وضعیت جلسه کاربر، مجدداً مجوز دهد.
/**
* The Sign-In client object.
*/
var auth2;
/**
* Initializes the Sign-In client.
*/
var initClient = function() {
gapi.load('auth2', function(){
/**
* Retrieve the singleton for the GoogleAuth library and set up the
* client.
*/
auth2 = gapi.auth2.init({
client_id: 'CLIENT_ID.apps.googleusercontent.com'
});
// Attach the click handler to the sign-in button
auth2.attachClickHandler('signin-button', {}, onSuccess, onFailure);
});
};
/**
* Handle successful sign-ins.
*/
var onSuccess = function(user) {
console.log('Signed in as ' + user.getBasicProfile().getName());
};
/**
* Handle sign-in failures.
*/
var onFailure = function(error) {
console.log(error);
};
تاریخ آخرین بهروزرسانی 2025-01-09 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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"]],["تاریخ آخرین بهروزرسانی 2025-01-09 بهوقت ساعت هماهنگ جهانی."],[[["The Google Sign-In JavaScript library is deprecated and will eventually be sunset; developers should consult the Deprecation and Sunset guide for migration details and timelines."],["Google Sign-In will require the use of FedCM APIs in the future, so developers should conduct an impact assessment to ensure their sign-in functionality remains unaffected."],["This page provides code demonstrating how to initialize the Google Sign-In client and attach click handlers to manage user sign-in and session state."],["Developers can utilize the `auth2` object to handle successful and failed sign-in attempts, accessing user information upon successful authentication."]]],[]]