어시스턴트용 Google 로그인은 가장 간단하고 쉬운 사용자 환경을 제공합니다.
사용자와 개발자에게 계정 연결 및 계정 생성을 지원합니다. 내 작업
대화 중에 사용자의 Google 프로필에 대한 액세스를 요청할 수 있으며,
사용자 이름, 이메일 주소, 프로필 사진 등이 포함됩니다.
프로필 정보는 개인화된 사용자 환경을 만드는 데 사용될 수 있습니다.
찾을 수 있습니다. 다른 플랫폼에 앱이 있고 이러한 앱에서 Google 로그인을 사용하는 경우
또한 기존 사용자 계정을 찾아 연결하거나, 새 계정을 만들거나,
사용자와의 직접적인 커뮤니케이션 채널을 구축해야 합니다
Google 로그인으로 계정 연결을 실행하려면 사용자에게 동의를 요청합니다.
Google 프로필에 액세스합니다. 그런 다음
예를 들어 이메일 주소를 사용하여 시스템에서 사용자를 식별합니다.
Google 로그인 계정 연결 구현
다음 섹션의 단계를 따라 Google 로그인 계정 연결을
액션.
프로젝트 구성
Google 로그인 계정 연결을 사용하도록 프로젝트를 구성하려면 다음 단계를 따르세요.
Actions 콘솔을 열고 프로젝트를 선택합니다.
개발 탭을 클릭하고 계정 연결을 선택합니다.
계정 연결 옆의 스위치를 켭니다.
계정 만들기 섹션에서 예를 선택합니다.
연결 유형에서 Google 로그인을 선택합니다.
클라이언트 정보를 열고 Google에서 작업에 발급한 클라이언트 ID 값을 기록해 둡니다.
새로운 장면을 만들어 작업에서 계정 연결을 시작합니다.
<ph type="x-smartling-placeholder"></ph>
장면을 클릭합니다.
add (+) 아이콘을 클릭하여 새 장면을 추가합니다.
새로 만든 장면에서 추가 add를 클릭합니다.
조건 아이콘
대화와 연결된 사용자가 다음에 해당하는지 확인하는 조건을 추가합니다.
인증된 사용자입니다. 검사를 통과하지 못하면 작업에서 계정 연결을 수행할 수 없습니다.
다시 돌아가
계정 연결이 필요하지 않은 기능입니다.
조건의 Enter new expression 필드에 다음 로직을 입력합니다.
user.verificationStatus != "VERIFIED"
전환에서 계정 연결이 필요하지 않은 장면을 선택하거나
게스트 전용 기능의 진입점인 장면입니다.
조건의 추가 add 아이콘을 클릭합니다.
사용자에게 계정이 없는 경우 계정 연결 흐름을 트리거하는 조건을 추가합니다.
계정을 만들 수 있습니다
조건의 Enter new expression 필드에 다음 로직을 입력합니다.
user.verificationStatus == "VERIFIED"
전환에서 계정 연결 시스템 장면을 선택합니다.
저장을 클릭합니다.
저장 후 새로운 계정 연결 시스템 장면(<SceneName>_AccountLinking)이 표시됩니다.
프로젝트에 추가됩니다
계정 연결 장면 맞춤설정하기
장면에서 계정 연결 시스템 장면을 선택합니다.
메시지 보내기를 클릭하고 사용자에게 설명할 짧은 문장을 추가합니다.
작업이 사용자의 ID에 액세스해야 하는 이유 (예: '환경설정 저장').
저장을 클릭합니다.
조건에서 사용자가 계정 연결을 완료한 경우를 클릭합니다.
사용자가 계정 연결에 동의하면 흐름이 어떻게 진행될지 구성합니다.
예를 들어 웹훅을 호출하여 필요한 커스텀 비즈니스 로직을 처리합니다.
원래 장면으로 다시 전환할 수 있습니다.
저장을 클릭합니다.
조건에서 사용자가 계정 연결을 취소하거나 닫는 경우를 클릭합니다.
사용자가
있습니다. 예를 들어 확인 메시지를 보내고 장면으로 리디렉션합니다.
계정 연결이 필요 없는 기능을 제공합니다.
저장을 클릭합니다.
조건에서 시스템 또는 네트워크 오류가 발생하는 경우를 클릭합니다.
계정 연결 흐름을 진행할 수 없는 경우 절차를 진행할 방법을 구성합니다.
사용자의 요청이 있을 수 있습니다.
예를 들어 확인 메시지를 보내고 장면으로 리디렉션합니다.
계정 연결이 필요 없는 기능을 제공합니다.
저장을 클릭합니다.
백엔드에서 프로필 정보에 액세스
사용자가 Google 프로필에 액세스하기 위한 작업을 승인하면 다음과 같은 알림을 받게 됩니다.
이후의 모든 도메인에 사용자의 Google 프로필 정보를 포함하는 Google ID 토큰
요청할 수 있습니다
사용자의 프로필 정보에 액세스하려면 먼저 토큰을 검증하고 디코딩해야 합니다.
방법은 다음과 같습니다.
해당 언어의 JWT 디코딩 라이브러리를 사용하여
Google의 공개 키 (JWK에서 제공)를 사용하여
또는 PEM 형식)을 사용하여 토큰의 서명을 확인합니다.
토큰 발급기관 (디코딩된 토큰의 iss 필드)이 https://accounts.google.com인지 확인
잠재고객 (디코딩된 토큰의 aud 필드)이
Google에서 내 작업에 발급한 클라이언트 ID로, 프로젝트에 할당됩니다.
확인할 수 있습니다
다음은 디코딩된 토큰의 예입니다.
{"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 ID로 어설션된 사용자가 맞는지 확인하기만 하면 됩니다.
토큰이 이미 데이터베이스에 있습니다. 다음 코드 스니펫은
다음은 사용자의 주문이 Firestore 데이터베이스에 이미 존재하는지 확인하는 방법의 예시입니다.
...app.handle('Place_Order',asyncconv=>{constorder=conv.session.params.order;constuserDoc=dbs.user.doc(conv.user.params.uid);constorderHistory=userDoc.collection("orderHistory");if(orderHistory){//Orderhistoryexists,sotheuseralreadyplacedanorder.//Updatecounterforordertype.awaitorderHistory.doc(order).update({count:admin.firestore.FieldValue.increment(1)});}else{//FirstordertheyplaceawaitorderHistory.doc(order).set({option:order,count:1});options.forEach(opt=>{if(opt!=order){orderHistory.doc(opt).set({option:opt,count:0});}});}returnconv.add(`Your ${order} has been placed. `+'Thanks for using Boba Bonanza, see you soon!');});
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eGoogle Sign-In for Assistant simplifies account linking and creation for both users and developers, enabling access to user profiles for personalized experiences.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage Google Sign-In to link or create user accounts across platforms, facilitating seamless user journeys and communication.\u003c/p\u003e\n"],["\u003cp\u003eImplementing Google Sign-In involves configuring the project in Actions Console, designing the authentication flow in Actions Builder, and handling data access requests securely in your backend.\u003c/p\u003e\n"],["\u003cp\u003eUser profile information, such as name, email, and profile picture, can be accessed after user authorization and token validation, allowing for customized interactions within the Action.\u003c/p\u003e\n"],["\u003cp\u003eActions using account linking for financial information are subject to additional policies and review, requiring compliance with financial services policies before submission.\u003c/p\u003e\n"]]],[],null,["Google Sign-In for the Assistant provides the simplest and easiest user experience\nto users and developers both for account linking and account creation. Your Action\ncan request access to your user's Google profile during a conversation,\nincluding the user's name, email address, and profile picture.\n\nThe profile information can be used to create a personalized user experience\nin your Action. If you have apps on other platforms and they use Google Sign-In,\nyou can also find and link to an existing user's account, create a new account,\nand establish a direct channel of communication to the user.\n\nTo perform account linking with Google Sign-In, you ask the user to give consent\nto access their Google profile. You then use the information in their profile, for\nexample their email address, to identify the user in your system.\n\nImplement Google Sign-In account linking\n\nFollow the steps in the following sections to add Google Sign-In account linking to your\nAction.\n| **Note:** If you're implementing account linking to handle financial information, note that additional policies may apply to your Action. It can take us up to six weeks to review an Action with account linking for financial information, so factor that time in when planning your release schedule. To ease the review process, make sure you comply with the [financial services policies](/assistant/console/policies/general-policies#financial_services) before submitting your Action for review.\n\nConfigure the project\n\nTo configure your project to use Google Sign-In account linking, follow these steps:\n\n1. Open the Actions Console and select a project.\n2. Click the **Develop** tab and choose **Account linking**.\n3. Enable the switch next to **Account linking**.\n4. In the **Account creation** section, select **Yes**.\n5. In **Linking type** , select **Google Sign In**.\n\n6. Open **Client Information** and take note of the value of **Client ID issued by Google to your Actions**.\n\n7. Click **Save**.\n\nDesign the voice user interface for the authentication flow **Warning:** Don't give users a required account linking prompt at the start of the conversation with your Action. Instead, give unauthenticated users a guest flow to show how your Action works, and then only ask for account linking if it's necessary to proceed. If users are leaving the Action consistently because of account linking issues, Google will not actively promote the Action, which may decrease the Action's user traffic.\n|\n|\n| **Note:** You must use [Actions Builder](/assistant/conversational/build#actions_builder) to build an Action that implements account linking.\n\nCheck if the user is verified and start the account linking flow\n\n1. Open your Actions Builder project in the [Actions Console](https://console.actions.google.com).\n2. Create a new scene to start account linking in your Action:\n 1. Click **Scenes**.\n 2. Click the **add** (+) icon to add a new scene.\n3. In the newly created scene, click the add *add* icon for **Conditions**.\n4. Add a condition that checks if the user associated with the conversation is a a verified user. If the check fails, your Action can't perform account linking during the conversation, and should fall back to providing access to functionality that doesn't require account linking.\n 1. In the `Enter new expression` field under **Condition** , enter the following logic: `user.verificationStatus != \"VERIFIED\"`\n 2. Under **Transition**, select a scene that doesn't require account linking or a scene that is the entry point to guest-only functionality.\n\n1. Click the add *add* icon for **Conditions**.\n2. Add a condition to trigger an account linking flow if the user doesn't have an associated identity.\n 1. In the `Enter new expression` field under **Condition** , enter the following logic:: `user.verificationStatus == \"VERIFIED\"`\n 2. Under **Transition** , select the **Account Linking** system scene.\n 3. Click **Save**.\n\nAfter saving, a new account linking system scene called `\u003cSceneName\u003e_AccountLinking`\nis added to your project.\n\nCustomize the account linking scene\n\n1. Under **Scenes**, select the account linking system scene.\n2. Click **Send prompt** and add a short sentence to describe to the user why the Action needs to access their identity (for example \"To save your preferences\").\n3. Click **Save**.\n\n1. Under **Conditions** , click **If user successfully completes account linking**.\n2. Configure how the flow should proceed if the user agrees to link their account. For example, call the webhook to process any custom business logic required and transition back to the originating scene.\n3. Click **Save**.\n\n1. Under **Conditions** , click **If user cancels or dismisses account linking**.\n2. Configure how the flow should proceed if the user doesn't agree to link their account. For example, send an acknowledging message and redirect to scenes that provide functionality that doesn't require account linking.\n3. Click **Save**.\n\n1. Under **Conditions** , click **If system or network error occurs**.\n2. Configure how the flow should proceed if the account linking flow can't be completed because of system or network errors. For example, send an acknowledging message and redirect to scenes that provide functionality that doesn't require account linking.\n3. Click **Save**.\n\nAccess profile information in your backend\n\nAfter the user authorizes your action to access their Google profile, you will receive\na Google ID token that contains the user's Google profile information in every subsequent\nrequest to your action.\n\nTo access the user's profile information, you need to first validate and decode the token\nby doing the following:\n\n1. Use a [JWT-decoding library](https://jwt.io/) for your language to decode the token, and use Google's public keys (available in [JWK](https://www.googleapis.com/oauth2/v3/certs) or [PEM](https://www.googleapis.com/oauth2/v1/certs) format) to verify the token's signature.\n2. Verify that the token's issuer (`iss` field in the decoded token) is `https://accounts.google.com` and that the audience (`aud` field in the decoded token) is the value of **Client ID issued by Google to your Actions**, which is assigned to your project in the Actions console.\n\nThe 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\nIf you use the [Actions on Google Fulfillment library for Node.js](https://github.com/actions-on-google/assistant-conversation-nodejs),\nit takes care of validating and decoding the token for you, and gives you access to\nthe profile content, as shown in the following code snippets. \n\n```gdscript\n...\nconst app = conversation({\n // REPLACE THE PLACEHOLDER WITH THE CLIENT_ID OF YOUR ACTIONS PROJECT\n clientId: CLIENT_ID,\n});\n...\n// Invoked on successful completion of account linking flow, check if we need to\n// create a Firebase user.\napp.handle('linkAccount', async conv =\u003e {\n let payload = conv.headers.authorization;\n if (payload) {\n // Get UID for Firebase auth user using the email of the user\n const email = payload.email;\n if (!conv.user.params.uid && email) {\n try {\n conv.user.params.uid = (await auth.getUserByEmail(email)).uid;\n } catch (e) {\n if (e.code !== 'auth/user-not-found') {\n throw e;\n }\n // If the user is not found, create a new Firebase auth user\n // using the email obtained from Google Assistant\n conv.user.params.uid = (await auth.createUser({email})).uid;\n }\n }\n }\n});\n```\n\nHandle data access requests\n\nTo handle data access request, just verify that the user asserted by the Google ID\ntoken is already present in your database. The following snippet of code shows\nan example of how to check if orders for a user already exist in a Firestore database: \n\n```perl\n...\napp.handle('Place_Order', async conv =\u003e {\n const order = conv.session.params.order;\n const userDoc = dbs.user.doc(conv.user.params.uid);\n const orderHistory = userDoc.collection(\"orderHistory\");\n if (orderHistory) {\n // Order history exists, so the user already placed an order.\n // Update counter for order type.\n await orderHistory.doc(order).update({ count: admin.firestore.FieldValue.increment(1)});\n } else {\n // First order they place\n await orderHistory.doc(order).set({ option: order, count: 1});\n options.forEach(opt =\u003e {\n if (opt != order) {\n orderHistory.doc(opt).set({ option: opt, count: 0});\n }\n });\n }\n return conv.add(`Your ${order} has been placed. ` +\n 'Thanks for using Boba Bonanza, see you soon!');\n});\n```\n\n\u003cbr /\u003e"]]