با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Google Sign-In (GSI) برای دستیار بینظیرترین تجربه پیوند را برای کاربران فراهم میکند و سادهترین جریان برای توسعهدهندگان است. با GSI، Action شما میتواند درخواست دسترسی به نمایه Google کاربر شما را در طول مکالمه کند و در صورت رضایت کاربر، نام، آدرس ایمیل و عکس نمایه کاربر را دریافت کند. سپس Action شما میتواند از این اطلاعات برای بررسی اینکه آیا کاربر یک حساب Google در سیستم شما دارد یا خیر استفاده کند. اگر نه، Action شما از کاربر میپرسد که آیا میخواهد یک حساب جدید در سیستم شما بر اساس اطلاعات نمایه Google خود ایجاد کند.
در صورت اعمال هر یک از موارد زیر، GSI راه حل پیشنهادی پیوند حساب است:
شما یک سیستم احراز هویت موجود ندارید و/یا انتظار دارید همه کاربران شما یک حساب Google داشته باشند. برای مثال، اگر Action شما بهطور خاص دستیار را هدف قرار میدهد، میتوانید انتظار داشته باشید که همه کاربرانتان حسابهای Google داشته باشند.
شما یک سیستم احراز هویت موجود دارید و فقط میخواهید کاربرانی را که با استفاده از حسابهای Google خود وارد سیستم شما شدهاند مرتبط کنید.
قبل از اینکه در مورد نحوه عملکرد GSI بخوانید، با اصطلاحات زیر آشنا شوید:
کد شناسه Google: یک ادعای امضا شده از هویت کاربر که حاوی اطلاعات اولیه نمایه Google کاربر (نام، آدرس ایمیل و عکس نمایه آنها) است. توکن Google ID یک نشانه وب JSON (JWT) است.
نمونه زیر نمونه ای از رمزگشایی شده است:
{"sub":1234567890,// The unique ID of the user's Google Account"iss":"https://accounts.google.com",// The token's issuer"aud":"123-abc.apps.googleusercontent.com",// Client ID assigned to your Actions project"iat":233366400,// Unix timestamp of the token's creation time"exp":233370000,// Unix timestamp of the token's expiration time"name":"Jan Jansen","given_name":"Jan","family_name":"Jansen","email":"jan@gmail.com",// If present, the user's email address"locale":"en_US"}
هدف کمکی ورود به حساب: هدف کمکی که برای درخواست جریان پیوند حساب از دستیار با آن تماس میگیرید. برای اطلاعات بیشتر، ورود به حساب را ببینید.
رشته زمینه: یک رشته سفارشی که به هدف کمکی ورود به سیستم حساب اضافه میکنید و به کاربر میگوید چرا به آن نیاز دارید تا حساب خود را پیوند دهد.
چگونه کار می کند
جریان اساسی برای GSI به شرح زیر است:
اقدام شما از کاربر برای دسترسی به نمایه Google خود رضایت میخواهد.
پس از رضایت کاربر، Action شما یک رمز Google ID دریافت می کند که حاوی اطلاعات نمایه Google کاربر است.
برای خواندن محتوای نمایه، رمز را اعتبارسنجی و رمزگشایی کنید. اگر از کتابخانه سرویس گیرنده Actions on Google برای Node.js یا کتابخانه سرویس گیرنده جاوا استفاده می کنید، رمز را برای شما تأیید و رمزگشایی می کند.
Your Action از این نشانه برای بررسی اینکه آیا اطلاعات نمایه Google کاربر در سیستم شما وجود دارد یا خیر استفاده می کند.
اگر اینطور باشد، کاربر قبلاً با حساب Google خود وارد سیستم شما شده است. کاربر میتواند با هویت مرتبط با حساب Google خود، مکالمه را با دستیار ادامه دهد.
اگر این کار را نکرد، کاربر می تواند با اطلاعات موجود در توکن Google ID یک حساب کاربری جدید در سیستم شما ایجاد کند. سپس کاربر میتواند با پیوند دادن حساب جدید خود با دستیار به گفتگو ادامه دهد.
جریان ورود به سیستم Google
این بخش جریان های مختلفی را که می تواند با Google Sign-in رخ دهد، توضیح می دهد.
جریان 1: اطلاعات کاربر در سیستم شما وجود دارد
نمودار زیر جریان انتها به انتها را نشان می دهد که با GSI زمانی که اطلاعات کاربر از قبل در سیستم شما وجود دارد رخ می دهد:
در این مورد، با یک رشته زمینه که سفارشی میکنید، actions.intent.SIGN_IN راهنما را فراخوانی میکنید. این هدف از کاربر برای دسترسی به اطلاعات نمایه Google خود اجازه می خواهد.
پس از رضایت کاربر، دستیار درخواستی را ارسال می کند که حاوی اطلاعات نمایه برای user@gmail.com است. در این حالت، اطلاعات موجود در رمز Google ID برای user@gmail.com با یک حساب در سیستم شما مطابقت دارد، بنابراین هویت کاربر در Action شما به طور خودکار به آن حساب مرتبط می شود. وبهوک شما میتواند سفارش معمول کاربر را از پایگاه داده بخواند و بر اساس آن پاسخ دهد.
جریان 2: اطلاعات کاربر در سیستم شما وجود ندارد
نمودار زیر جریان سرتاسری را نشان میدهد که با GSI زمانی که اطلاعات کاربر در سیستم شما وجود ندارد رخ میدهد:
در این حالت، اطلاعات موجود در رمز Google ID برای user@gmail.com با حسابی در سیستم شما مطابقت ندارد، بنابراین دستیار از کاربر میپرسد که آیا مایل به ایجاد حساب جدید است یا خیر. کاربر می تواند فرآیند ایجاد حساب را به جای انتقال به یک دستگاه غربال شده، با صدا کامل کند.
هنگامی که کاربر با ایجاد حساب موافقت می کند، سرویس شما از اطلاعات موجود در شناسه شناسه (نام و آدرس ایمیل کاربر) برای ایجاد حساب کاربری برای کاربر استفاده می کند. پس از ایجاد حساب، هویت کاربر در Action شما به حساب Google جدید وی مرتبط می شود.
در این حالت، کاربر سفارش معمولی ندارد زیرا او در سرویس جدید است، بنابراین Action شما از شما میپرسد که چه چیزی میخواهد سفارش دهد. همچنین میتوانید از کاربر بپرسید که آیا میخواهد جدیدترین سفارش خود را به عنوان سفارش معمول خود تنظیم کند.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGoogle Sign-In (GSI) offers a seamless account linking experience for Assistant users and is the easiest for developers to implement, allowing Actions to request access to a user's Google profile for name, email, and picture for account verification or creation.\u003c/p\u003e\n"],["\u003cp\u003eGSI is recommended if you lack an existing authentication system, expect all users to have Google accounts, or want to link users who have signed in using their Google accounts.\u003c/p\u003e\n"],["\u003cp\u003eUpon user consent, your Action receives a Google ID token containing user profile information, which is used to check if the user exists in your system; if so, the user is linked; if not, the user is prompted to create a new account using their Google profile.\u003c/p\u003e\n"],["\u003cp\u003eIf a user's information isn't found, they can create a new account using their Google profile, and their identity in your Action is linked to their new Google account.\u003c/p\u003e\n"]]],["Google Sign-In (GSI) allows Actions to request user's Google profile information (name, email, picture) with user consent. If the user's information exists in the system, their identity is automatically linked; otherwise, the user can create a new account using their Google profile. The Action receives a Google ID token, validates and decodes it. The user can continue using the Action after the linking of the Google account. User can be a guest if they can not be identified.\n"],null,["# Google Sign-In concept guide (Dialogflow)\n\nGoogle Sign-In (GSI) for the Assistant provides the most seamless linking\nexperience for users and is the easiest flow for developers to implement.\nWith GSI, your Action can request access to your user's Google profile during\na conversation and, if the user consents, receive the user's name, email address,\nand profile picture. Your Action can then use this information to check if the\nuser has a Google account in your system. If not, your Action asks the user if\nthey want to create a new account in your system based on their Google\nprofile information.\n| **Note:** Your user is either a) identified through voice recognition or b) configured on the device. If the user's voice is verified but not recognized, the user is considered a guest.\n\nGSI is the recommended account linking solution if any of the following applies:\n\n- You don't have an existing authentication system and/or you expect all your users to have a Google account. For example, if your Action is specifically targeting the Assistant, you can expect all your users to have Google accounts.\n- You have an existing authentication system and only want to link users who signed into your system using their Google accounts.\n\nTo verify that GSI is the right solution for you, see the\n[Choose your account linking type](/assistant/df-asdk/identity/choose-type) page.\n\nKey terms\n---------\n\nBefore you read about how GSI works, familiarize yourself with the following terms:\n\n- **Google ID token:** A signed assertion of a user's identity that contains\n a user's basic Google profile information (their name, email address, and\n profile picture). A Google ID token is a\n [JSON Web Token](https://en.wikipedia.org/wiki/JSON_Web_Token)\n (JWT).\n\n The following is an example of a decoded token:\n\n```carbon\n{\n \"sub\": 1234567890, // The unique ID of the user's Google Account\n \"iss\": \"https://accounts.google.com\", // The token's issuer\n \"aud\": \"123-abc.apps.googleusercontent.com\", // Client ID assigned to your Actions project\n \"iat\": 233366400, // Unix timestamp of the token's creation time\n \"exp\": 233370000, // Unix timestamp of the token's expiration time\n \"name\": \"Jan Jansen\",\n \"given_name\": \"Jan\",\n \"family_name\": \"Jansen\",\n \"email\": \"jan@gmail.com\", // If present, the user's email address\n \"locale\": \"en_US\"\n}\n```\n\n- **Account sign-in helper intent:** A helper intent that you call to request an account linking flow from the Assistant. For more information, see [Account Sign-in](/assistant/df-asdk/helpers#account_sign-in).\n - **Context string:** A customized string that you add to the account sign-in helper intent that tells the user why you need them to link their account.\n\nHow it works\n------------\n\nThe fundamental flow for GSI is as follows:\n\n1. Your Action asks the user for consent to access their Google profile.\n2. After the user gives consent, your Action receives a Google ID token that contains the user's Google profile information.\n3. Validate and decode the token to read the profile content. If you use the Actions on Google client library for Node.js or the Java client library, it validates and decodes the token for you.\n4. Your Action uses this token to check if the user's Google profile\n information exists in your system.\n\n 1. If it does, the user has already signed into your system with their Google account. The user can continue the conversation with the Assistant with their identity linked to their Google account.\n 2. If it doesn't, the user can create a new account in your system with\n the information contained in the Google ID token. The user can then\n continue the conversation with the Assistant with their new account linked.\n\n | **Note:** New accounts do not typically have a password set. It is recommended that you add Google Sign In to other platforms to enable users to log in via Google across the surfaces of your application. Alternatively, you can email the user a link that starts your password recovery flow to allow the user to set a password for signing in on other platforms.\n\nGoogle Sign-in flows\n--------------------\n\nThis section describes the various flows that can occur with Google Sign-in.\n| **Note:** The following flows assume the user gives consent for your Action to access their Google profile information. If a user doesn't give consent, provide them a way to continue in your Action with an alternate, limited flow. For more information, see [Best practices](/assistant/df-asdk/identity/best-practices).\n\n### Flow 1: User's information exists in your system\n\nThe following diagram shows the end-to-end flow that occurs with GSI when the\nuser's information already exists in your system:\n\n| **Note:** A line from *Webhook* to *User* represents a [simple response](/assistant/df-asdk/simple-responses) that you create and customize. Lines drawn from *Assistant* to *User* represent prompts that are owned by the Assistant and have limited options for customization (requests that require permission are always owned by the Assistant). From the user's perspective, both kinds of responses are delivered from the Assistant.\n\nIn this case, you call the `actions.intent.SIGN_IN` helper intent with a\ncontext string you customize. This intent asks the user for permission to\naccess their Google profile information.\n\nAfter the user consents, the Assistant sends a request that contains the\nprofile information for `user@gmail.com`. In this case, the information\ncontained in the Google ID token for `user@gmail.com` matches an account in\nyour system, so the user's identity in your Action is automatically linked\nto that account. Your webhook can then read the user's usual order from\na database and respond accordingly.\n\n### Flow 2: User's information does not exist in your system\n\nThe following diagram shows the end-to-end flow that occurs with GSI when\nthe user's information does not exist in your system:\n\nIn this case, the information contained in the Google ID token for\n`user@gmail.com` does not match an account in your system, so the Assistant\nasks the user if they'd like to create a new account. The user can complete\nthe account creation process with voice rather than transferring to\na screened device.\n\nWhen the user agrees to create an account, your service uses the information\nin the ID token (the user's name and email address) to create an account for\nthe user. Once the account is created, the user's identity in your Action\nis linked to their new Google account.\n\nIn this case, the user does not have a usual order because they are new to\nthe service, so your Action asks what they want to order. You\ncan also ask the user if they'd like to set their most recent order\nas their usual order."]]