Google 助理的 Google 登入 (GSI) 提供最流暢的連結
也是開發人員最容易實作的流程。
有了 GSI,您的動作可在以下期間要求存取使用者的 Google 個人資料
對話,並在使用者同意後接收使用者名稱和電子郵件地址。
和個人資料相片你的動作就能根據這項資訊來檢查
使用者在系統中擁有 Google 帳戶。如果不是,您的動作會詢問使用者是否
他們想要根據您的 Google
個人資料內容
如果符合下列任一情況,則建議使用 GSI 做為帳戶連結解決方案:
您本身沒有驗證系統,且/或希望您的
使用者必須擁有 Google 帳戶。舉例來說,如果您的動作
我們希望所有使用者都能使用
帳戶。
Google ID 權杖:經簽署的使用者身分宣告,當中包含
使用者的基本 Google 個人資料資訊 (包括姓名、電子郵件地址和
個人資料相片) 即可。Google ID 權杖
JSON Web Token
(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"}
帳戶登入協助程式意圖:您呼叫的輔助意圖
向 Google 助理要求帳戶連結流程如需更多資訊
請參閱「帳戶登入」。
內容字串:您加進帳戶的自訂字串
登入輔助意圖,向使用者說明該連結的原因
他們的帳戶。
運作方式
GSI 的基本流程如下:
您的動作要求使用者同意存取其 Google 個人資料。
使用者提供同意聲明後,您的動作會收到 Google ID 權杖。
包含使用者的 Google 個人資料資訊。
驗證權杖並解碼,以便讀取個人資料內容。如果您使用
Actions on Google 用戶端程式庫 for Node.js 或 Java 用戶端程式庫,
就會為您驗證符記並加以解碼
你的動作會使用這個權杖檢查使用者的 Google 個人資料
才是有效的資訊
如果有,表示使用者已使用
Google 帳戶。使用者可以繼續與
Google 助理,會將孩子的身分與他們的 Google 帳戶連結。
如果沒有的話,使用者可以使用
Google ID 權杖包含的資訊這樣一來,使用者就能
繼續透過已連結 Google 助理的帳戶繼續對話。
Google 登入流程
本節說明使用 Google 登入功能可能發生的各種流程。
流程 1:使用者資訊存在於系統中
下圖顯示使用 GSI 時發生的
使用者的資訊已存在於您的系統中:
在此情況下,您可以使用 actions.intent.SIGN_IN 輔助意圖來呼叫
您自訂的內容字串此意圖會要求使用者授予權限
存取自己的 Google 個人資料。
使用者同意後,Google 助理會傳送內含
user@gmail.com 的個人資料資訊。在本例中
包含在 user@gmail.com 的 Google ID 權杖中,與
系統因此,動作會自動連結使用者在動作中的身分
。這樣一來,您的 Webhook 就能透過
並提供相應回應
流程 2:使用者資訊不存在於您的系統中
下圖顯示使用 GSI 時發生的
使用者的資訊不存在在您的系統中:
在此情況下,Google ID 權杖所含資訊
「user@gmail.com」與系統中的帳戶不相符,因此 Google 助理
詢問使用者是否要建立新帳戶。使用者可以完成
使用語音建立帳戶,不用將帳戶轉給對方
遭到過濾的裝置。
如果使用者同意建立帳戶,您的服務就會使用
建立專屬帳戶
使用者。建立帳戶之後,使用者在動作中看見的身分
並連結至新的 Google 帳戶。
[[["容易理解","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-07-26 (世界標準時間)。"],[[["\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,[]]