การลิงก์บัญชีด้วย Google Sign-In ที่ใช้ OAuth "ปรับปรุง"

การลิงก์ Google Sign-In แบบ "ปรับปรุงให้ดียิ่งขึ้น" แบบ OAuth จะเพิ่ม Google Sign-In เพิ่มเติมจากการลิงก์บัญชีแบบ OAuth วิธีนี้ช่วยให้ผู้ใช้ Google ลิงก์ด้วยเสียงได้อย่างราบรื่น ขณะเดียวกันก็เปิดใช้การลิงก์บัญชีสำหรับผู้ใช้ที่ลงทะเบียนบริการด้วยข้อมูลประจำตัวที่ไม่ใช่ของ Google ด้วย

การลิงก์ประเภทนี้จะเริ่มต้นด้วย Google Sign-In ซึ่งให้คุณตรวจสอบได้ว่ามีข้อมูลโปรไฟล์ Google ของผู้ใช้อยู่ในระบบของคุณหรือไม่ หากไม่พบข้อมูลของผู้ใช้ในระบบของคุณ ขั้นตอน OAuth มาตรฐานจะเริ่มต้น ผู้ใช้ยังสามารถเลือกสร้างบัญชีใหม่ด้วยข้อมูลโปรไฟล์ Google ของตนเองได้อีกด้วย

รูปที่ 1: หลังจากที่การดำเนินการของคุณเข้าถึงโปรไฟล์ Google ของผู้ใช้แล้ว คุณสามารถใช้เพื่อค้นหาชื่อที่ตรงกันสำหรับผู้ใช้ในระบบการตรวจสอบสิทธิ์ของคุณได้

หากต้องการลิงก์บัญชีด้วยประเภทการลิงก์ที่ปรับปรุงใหม่ ให้ทำตามขั้นตอนทั่วไปต่อไปนี้

  1. ขั้นแรก ขอให้ผู้ใช้ให้คำยินยอมในการเข้าถึงโปรไฟล์ Google ของตน
  2. ใช้ข้อมูลในโปรไฟล์เพื่อระบุตัวผู้ใช้
  3. หากไม่พบข้อมูลที่ตรงกันสำหรับผู้ใช้ Google ในระบบการตรวจสอบสิทธิ์ ขั้นตอนการดำเนินการจะดำเนินต่อไปโดยขึ้นอยู่กับว่าคุณได้กำหนดค่าโปรเจ็กต์ Actions ในคอนโซล Actions เพื่ออนุญาตการสร้างบัญชีผู้ใช้ด้วยเสียงหรือดำเนินการในเว็บไซต์เท่านั้น
    • หากคุณอนุญาตให้สร้างบัญชีผ่านทางเสียง ให้ตรวจสอบโทเค็นรหัสที่ได้รับจาก Google จากนั้นคุณสามารถสร้างผู้ใช้ตามข้อมูลโปรไฟล์ที่มีอยู่ในโทเค็นรหัส
    • หากคุณไม่อนุญาตให้สร้างบัญชีผ่านเสียง ระบบจะโอนผู้ใช้ไปยังเบราว์เซอร์ที่ผู้ใช้จะโหลดหน้าการให้สิทธิ์และทำตามขั้นตอนการสร้างผู้ใช้จนเสร็จ
หากคุณอนุญาตให้สร้างบัญชีผ่านเสียงและไม่พบข้อมูลที่ตรงกันสำหรับโปรไฟล์ Google ในระบบการตรวจสอบสิทธิ์ คุณจะต้องตรวจสอบโทเค็นรหัสที่ได้รับจาก Google จากนั้นคุณจะสร้างผู้ใช้ตามข้อมูลโปรไฟล์ที่มีอยู่ในโทเค็นรหัสได้
            หากคุณไม่อนุญาตให้สร้างบัญชีผู้ใช้ผ่านเสียง ระบบจะ
            โอนผู้ใช้ไปยังเบราว์เซอร์ที่ผู้ใช้จะโหลดหน้าการให้สิทธิ์
            และดำเนินการตามขั้นตอนจนเสร็จสิ้นได้
รูปที่ 2 ภาพแสดงขั้นตอน OAuth และ Google Sign-In เมื่อไม่พบข้อมูลของผู้ใช้ในระบบ

รองรับการสร้างบัญชีผ่านเสียง

หากคุณอนุญาตให้สร้างบัญชีผู้ใช้ผ่านเสียง Assistant จะถามผู้ใช้ว่าต้องการทำสิ่งต่อไปนี้หรือไม่

  • สร้างบัญชีใหม่ในระบบของคุณโดยใช้ข้อมูลบัญชี Google หรือ
  • ลงชื่อเข้าใช้ระบบการตรวจสอบสิทธิ์ด้วยบัญชีอื่นหากบัญชีมีบัญชีที่ไม่ใช่ของ Google อยู่

เราขอแนะนำให้อนุญาตให้สร้างบัญชีผ่านเสียงหากต้องการลดความยุ่งยากในขั้นตอนการสร้างบัญชี ผู้ใช้ต้องออกจากขั้นตอนการสั่งงานด้วยเสียง เมื่อต้องการลงชื่อเข้าใช้โดยใช้บัญชีที่ไม่ใช่ของ Google ที่มีอยู่

ไม่อนุญาตให้สร้างบัญชีผ่านเสียง

หากคุณไม่อนุญาตให้สร้างบัญชีผู้ใช้ผ่านเสียง Assistant จะเปิด URL ของเว็บไซต์ที่คุณให้ไว้สำหรับการตรวจสอบสิทธิ์ผู้ใช้ หากการโต้ตอบเกิดขึ้นในอุปกรณ์ที่ไม่มีหน้าจอ Assistant จะนำผู้ใช้ไปยังโทรศัพท์เพื่อดำเนินการลิงก์บัญชีต่อ

เราขอแนะนำให้ไม่อนุญาตให้สร้างในกรณีต่อไปนี้

  • คุณไม่ต้องการให้ผู้ใช้ที่มีบัญชีที่ไม่ใช่ของ Google สามารถสร้างบัญชีผู้ใช้ใหม่ และต้องการให้เชื่อมโยงกับบัญชีผู้ใช้ที่มีอยู่เดิมในระบบการตรวจสอบสิทธิ์แทน เช่น ถ้าคุณนำเสนอโปรแกรมสะสมคะแนน คุณอาจต้องการตรวจสอบว่าผู้ใช้จะไม่สูญเสียคะแนนสะสมในบัญชีที่มีอยู่

  • คุณต้องควบคุมขั้นตอนการสร้างบัญชีได้อย่างสมบูรณ์ เช่น คุณไม่อนุญาตให้สร้างได้หากต้องการแสดงข้อกำหนดในการให้บริการแก่ผู้ใช้ในระหว่างการสร้างบัญชี

ใช้การลิงก์ "ปรับปรุง" ใน Google Sign-In ที่ใช้ OAuth

โดยบัญชีต่างๆ จะเชื่อมโยงกับขั้นตอน OAuth 2.0 ที่เป็นมาตรฐานอุตสาหกรรม Actions on Google รองรับขั้นตอนของรหัสการให้สิทธิ์และโดยนัย

เพื่อช่วยให้กระบวนการตรวจสอบง่ายขึ้น

ในขั้นตอนการเขียนโค้ดแบบโดยนัย Google จะเปิดปลายทางการให้สิทธิ์ในเบราว์เซอร์ของผู้ใช้ เมื่อลงชื่อเข้าใช้สําเร็จ คุณจะส่งคืนโทเค็นเพื่อการเข้าถึงที่ใช้ได้นานแก่ Google ตอนนี้โทเค็นเพื่อการเข้าถึงนี้รวมอยู่ในคําขอทุกรายการที่ส่งจาก Assistant ไปยังการดําเนินการของคุณแล้ว

ในกระบวนการรหัสการให้สิทธิ์ คุณต้องมีปลายทาง 2 จุด ได้แก่

  • ปลายทางการให้สิทธิ์ ซึ่งมีหน้าที่นําเสนอ UI การลงชื่อเข้าใช้แก่ผู้ใช้ที่ไม่ได้ลงชื่อเข้าใช้ และยินยอมให้มีการเข้าถึงการเข้าถึงที่ขอในรูปของรหัสการให้สิทธิ์ระยะสั้น
  • ปลายทางของการแลกเปลี่ยนโทเค็นที่มีหน้าที่รับผิดชอบการแลกเปลี่ยน 2 ประเภท ได้แก่
    1. แลกเปลี่ยนรหัสการให้สิทธิ์สําหรับโทเค็นการรีเฟรชที่ใช้ได้นานและโทเค็นเพื่อการเข้าถึงที่ใช้ได้นาน การแลกเปลี่ยนนี้จะเกิดขึ้นเมื่อผู้ใช้เข้าสู่ กระบวนการเชื่อมโยงบัญชี
    2. แลกเปลี่ยนโทเค็นการรีเฟรชที่ใช้ได้นานกับโทเค็นเพื่อการเข้าถึงที่ใช้ได้ในระยะสั้น Exchange นี้จะเกิดขึ้นเมื่อ Google ต้องการโทเค็นเพื่อการเข้าถึงใหม่เนื่องจากโทเค็นหมดอายุ

แม้ว่าขั้นตอนการใช้รหัสโดยนัยจะง่ายกว่า Google ขอแนะนําว่าโทเค็นเพื่อการเข้าถึงที่ออกโดยใช้โฟลว์โดยนัยไม่มีวันหมดอายุ เนื่องจากการใช้การหมดอายุของโทเค็นด้วยขั้นตอนโดยนัยบังคับให้ผู้ใช้ลิงก์บัญชีอีกครั้ง หากคุณต้องการใช้การหมดอายุของโทเค็นด้วยเหตุผลด้านความปลอดภัย คุณควรพิจารณาการใช้ขั้นตอนการตรวจสอบสิทธิ์แทน

กำหนดค่าโปรเจ็กต์

หากต้องการกําหนดค่าโปรเจ็กต์ให้ใช้การลิงก์ที่มีประสิทธิภาพมากขึ้น ให้ทําตามขั้นตอนต่อไปนี้

  1. เปิดคอนโซล Actions แล้วเลือกโปรเจ็กต์ที่ต้องการใช้
  2. คลิกแท็บพัฒนา และเลือกการลิงก์บัญชี
  3. เปิดใช้สวิตช์ถัดจากการลิงก์บัญชี
  4. เลือกใช่ในส่วนการสร้างบัญชี

  5. ในส่วนประเภทการลิงก์ ให้เลือก OAuth และ Google Sign In และโดยนัย

  6. ในส่วนข้อมูลลูกค้า ให้ทำดังนี้

    • กำหนดค่ารหัสลูกค้าที่ออกโดย Actions to Google เพื่อระบุคำขอที่มาจาก Google
    • ใส่ URL สำหรับปลายทางการให้สิทธิ์และการแลกเปลี่ยนโทเค็น
  7. คลิกบันทึก

ใช้งานเซิร์ฟเวอร์ OAuth

บริการของคุณจะให้สิทธิ์เพื่อรองรับขั้นตอนโดยนัยของ OAuth 2.0 ปลายทางที่พร้อมใช้งานผ่าน HTTPS ปลายทางนี้มีหน้าที่ในการตรวจสอบสิทธิ์และ ได้รับความยินยอมจากผู้ใช้ในการเข้าถึงข้อมูล ปลายทางการให้สิทธิ์ แสดง UI การลงชื่อเข้าใช้แก่ผู้ใช้ที่ยังไม่ได้ลงชื่อเข้าใช้และบันทึกไว้ ความยินยอมต่อการเข้าถึงที่ขอ

เมื่อการดำเนินการของคุณจำเป็นต้องเรียกใช้ API ที่ได้รับอนุญาตของบริการ Google จะใช้ ปลายทางนี้เพื่อขอสิทธิ์จากผู้ใช้เพื่อเรียกใช้ API เหล่านี้ใน แทน

เซสชันโฟลว์แบบโดยนัยของ OAuth 2.0 ทั่วไปที่ Google เป็นผู้เริ่มต้นจะมี ขั้นตอนดังต่อไปนี้

  1. Google จะเปิดปลายทางการให้สิทธิ์ในเบราว์เซอร์ของผู้ใช้ ผู้ใช้ ลงชื่อเข้าใช้หากยังไม่ได้ลงชื่อเข้าใช้ และให้สิทธิ์แก่ Google ในการเข้าถึง ข้อมูลของตนเองกับ API ของคุณ หากผู้ใช้ยังไม่ได้ให้สิทธิ์
  2. บริการของคุณจะสร้างโทเค็นเพื่อการเข้าถึงและส่งไปยัง Google โดยการเปลี่ยนเส้นทางเบราว์เซอร์ของผู้ใช้กลับไปยัง Google ด้วยโทเค็นเพื่อการเข้าถึง ที่แนบมากับคำขอ
  3. Google จะเรียกใช้ API ของบริการ และแนบโทเค็นเพื่อการเข้าถึงกับ คำขอแต่ละรายการ บริการของคุณยืนยันว่าโทเค็นเพื่อการเข้าถึงให้สิทธิ์ Google การอนุญาตให้เข้าถึง API จากนั้นจึงเรียก API

จัดการคำขอการให้สิทธิ์

เมื่อการดำเนินการของคุณต้องลิงก์บัญชีผ่านขั้นตอนโดยนัยของ OAuth 2.0 Google จะส่งผู้ใช้ไปยังปลายทางการให้สิทธิ์พร้อมคำขอที่มี พารามิเตอร์ต่อไปนี้

พารามิเตอร์ปลายทางการให้สิทธิ์
client_id รหัสไคลเอ็นต์ที่คุณกำหนดให้กับ Google
redirect_uri URL ที่คุณส่งการตอบกลับคำขอนี้
state มูลค่าการทำบัญชีที่ส่งกลับไปยัง Google ไม่เปลี่ยนแปลงใน URI การเปลี่ยนเส้นทาง
response_type ประเภทของค่าที่จะแสดงในคำตอบ สำหรับ OAuth 2.0 โดยปริยาย ประเภทการตอบกลับจะเป็น token เสมอ

ตัวอย่างเช่น หากปลายทางการให้สิทธิ์อยู่ที่ https://myservice.example.com/auth คำขออาจมีลักษณะดังนี้

GET https://myservice.example.com/auth?client_id=GOOGLE_CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE_STRING&response_type=token

สำหรับปลายทางการให้สิทธิ์ในการจัดการคำขอลงชื่อเข้าใช้ ให้ทำตามขั้นตอนต่อไปนี้

  1. ยืนยันค่า client_id และ redirect_uri เพื่อ ป้องกันการให้สิทธิ์เข้าถึงแอปไคลเอ็นต์ที่ไม่ได้ตั้งใจหรือกำหนดค่าไม่ถูกต้อง

    • ยืนยันว่า client_id ตรงกับรหัสไคลเอ็นต์ที่คุณ ที่มอบหมายให้กับ Google
    • ยืนยันว่า URL ที่ระบุโดย redirect_uri จะมีรูปแบบต่อไปนี้ วันที่
      https://oauth-redirect.googleusercontent.com/r/YOUR_PROJECT_ID
      YOUR_PROJECT_ID คือรหัสในหน้าการตั้งค่าโปรเจ็กต์ ของคอนโซลการดำเนินการ
  2. ตรวจสอบว่าผู้ใช้ลงชื่อเข้าใช้บริการของคุณหรือไม่ หากผู้ใช้ไม่ได้เซ็น ดำเนินการตามขั้นตอนการลงชื่อเข้าใช้หรือลงชื่อสมัครใช้บริการของคุณ

  3. สร้างโทเค็นเพื่อการเข้าถึงที่ Google จะใช้เพื่อเข้าถึง API ของคุณ โทเค็นเพื่อการเข้าถึงสามารถเป็นค่าสตริงใดก็ได้ แต่จะต้องแสดงถึง ผู้ใช้และไคลเอ็นต์ที่ใช้โทเค็นและต้องคาดเดาไม่ได้

  4. ส่งการตอบกลับ HTTP ที่เปลี่ยนเส้นทางเบราว์เซอร์ของผู้ใช้ไปยัง URL ที่ระบุโดยพารามิเตอร์ redirect_uri รวม พารามิเตอร์ต่อไปนี้ในส่วนย่อยของ URL

    • access_token: โทเค็นเพื่อการเข้าถึงที่คุณเพิ่งสร้าง
    • token_type: สตริง bearer
    • state: ค่าสถานะที่ไม่มีการแก้ไขจากค่าเดิม คำขอ ตัวอย่างของ URL ที่ได้มีดังนี้ วันที่
      https://oauth-redirect.googleusercontent.com/r/YOUR_PROJECT_ID#access_token=ACCESS_TOKEN&token_type=bearer&state=STATE_STRING

เครื่องจัดการการเปลี่ยนเส้นทาง OAuth 2.0 ของ Google จะได้รับโทเค็นเพื่อการเข้าถึงและยืนยัน ค่า state ยังไม่มีการเปลี่ยนแปลง หลังจากที่ Google ได้รับ โทเค็นเพื่อการเข้าถึงสำหรับบริการของคุณ Google จะแนบโทเค็นไปกับการเรียกครั้งต่อๆ ไป ไปยังการดำเนินการของคุณได้โดยเป็นส่วนหนึ่งของ AppRequest

Handle automatic linking

After the user gives your Action consent to access their Google profile, Google sends a request that contains a signed assertion of the Google user's identity. The assertion contains information that includes the user's Google Account ID, name, and email address. The token exchange endpoint configured for your project handles that request.

If the corresponding Google account is already present in your authentication system, your token exchange endpoint returns a token for the user. If the Google account doesn't match an existing user, your token exchange endpoint returns a user_not_found error.

The request has the following form:

POST /token HTTP/1.1
Host: oauth2.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&intent=get&assertion=JWT&consent_code=CONSENT_CODE&scope=SCOPES

Your token exchange endpoint must be able to handle the following parameters:

Token endpoint parameters
grant_type The type of token being exchanged. For these requests, this parameter has the value urn:ietf:params:oauth:grant-type:jwt-bearer.
intent For these requests, the value of this parameter is `get`.
assertion A JSON Web Token (JWT) that provides a signed assertion of the Google user's identity. The JWT contains information that includes the user's Google Account ID, name, and email address.
consent_code Optional: When present, a one-time code that indicates that the user has granted consent for your Action to access the specified scopes.
scope Optional: Any scopes you configured Google to request from users.

When your token exchange endpoint receives the linking request, it should do the following:

Validate and decode the JWT assertion

You can validate and decode the JWT assertion by using a JWT-decoding library for your language. Use Google's public keys (available in JWK or PEM format) to verify the token's signature.

When decoded, the JWT assertion looks like the following example:

{
  "sub": 1234567890,        // The unique ID of the user's Google Account
  "iss": "https://accounts.google.com",        // The assertion's issuer
  "aud": "123-abc.apps.googleusercontent.com", // Your server's client ID
  "iat": 233366400,         // Unix timestamp of the assertion's creation time
  "exp": 233370000,         // Unix timestamp of the assertion'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"
}

In addition to verifying the token's signature, verify that the assertion's issuer (iss field) is https://accounts.google.com and that the audience (aud field) is the client ID assigned to your Action.

Check if the Google account is already present in your authentication system

Check whether either of the following conditions are true:

  • The Google Account ID, found in the assertion's sub field, is in your user database.
  • The email address in the assertion matches a user in your user database.

If either condition is true, the user has already signed up and you can issue an access token.

If neither the Google Account ID nor the email address specified in the assertion matches a user in your database, the user hasn't signed up yet. In this case, your token exchange endpoint should reply with a HTTP 401 error, that specifies error=user_not_found, as in the following example:

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8

{
  "error":"user_not_found",
}
When Google receives the 401 error response with a user_not_found error, Google calls your token exchange endpoint with the value of the intent parameter set to create and sending an ID token that contains the user's profile information with the request.

Handle account creation via Google Sign-In

When a user needs to create an account on your service, Google makes a request to your token exchange endpoint that specifies intent=create, as in the following example:

POST /token HTTP/1.1
Host: oauth2.example.com
Content-Type: application/x-www-form-urlencoded

response_type=token&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&scope=SCOPES&intent=create&consent_code=CONSENT_CODE&assertion=JWT[&NEW_ACCOUNT_INFO]

The assertion parameter contains A JSON Web Token (JWT) that provides a signed assertion of the Google user's identity. The JWT contains information that includes the user's Google Account ID, name, and email address, which you can use to create a new account on your service.

To respond to account creation requests, your token exchange endpoint must do the following:

Validate and decode the JWT assertion

You can validate and decode the JWT assertion by using a JWT-decoding library for your language. Use Google's public keys (available in JWK or PEM format) to verify the token's signature.

When decoded, the JWT assertion looks like the following example:

{
  "sub": 1234567890,        // The unique ID of the user's Google Account
  "iss": "https://accounts.google.com",        // The assertion's issuer
  "aud": "123-abc.apps.googleusercontent.com", // Your server's client ID
  "iat": 233366400,         // Unix timestamp of the assertion's creation time
  "exp": 233370000,         // Unix timestamp of the assertion'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"
}

In addition to verifying the token's signature, verify that the assertion's issuer (iss field) is https://accounts.google.com and that the audience (aud field) is the client ID assigned to your Action.

Validate user information and create new account

Check whether either of the following conditions are true:

  • The Google Account ID, found in the assertion's sub field, is in your user database.
  • The email address in the assertion matches a user in your user database.

If either condition is true, prompt the user to link their existing account with their Google Account by responding to the request with an HTTP 401 error, specifying error=linking_error and the user's email address as the login_hint, as in the following example:

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8

{
  "error":"linking_error",
  "login_hint":"foo@bar.com"
}

If neither condition is true, create a new user account using the information provided in the JWT. 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.

When the creation is completed, issue an access token and return the values in a JSON object in the body of your HTTPS response, like in the following example:

{
  "token_type": "Bearer",
  "access_token": "ACCESS_TOKEN",
  
  "expires_in": SECONDS_TO_EXPIRATION
}

ออกแบบอินเทอร์เฟซผู้ใช้แบบเสียงสำหรับขั้นตอนการตรวจสอบสิทธิ์

ตรวจสอบว่าผู้ใช้ได้รับการยืนยันหรือไม่ และเริ่มขั้นตอนการลิงก์บัญชี

  1. เปิดโปรเจ็กต์ Actions Builder ในคอนโซล Actions
  2. สร้างฉากใหม่เพื่อเริ่มลิงก์บัญชีใน Action ของคุณ
    1. คลิกฉาก
    2. คลิกไอคอนเพิ่ม (+) เพื่อเพิ่มฉากใหม่
  3. ในโหมดที่สร้างขึ้นใหม่ ให้คลิกไอคอนเพิ่ม สำหรับเงื่อนไข
  4. เพิ่มเงื่อนไขที่ตรวจสอบว่าผู้ใช้ที่เชื่อมโยงกับการสนทนาเป็นผู้ใช้ที่ได้รับการยืนยันหรือไม่ หากการตรวจสอบไม่สำเร็จ การดำเนินการของคุณจะไม่สามารถลิงก์บัญชีในระหว่างการสนทนา และควรกลับไปให้สิทธิ์เข้าถึงฟังก์ชันการทำงานที่ไม่จำเป็นต้องมีการลิงก์บัญชี
    1. ในช่อง Enter new expression ในส่วนเงื่อนไข ให้ป้อนตรรกะต่อไปนี้ user.verificationStatus != "VERIFIED"
    2. ในส่วนการเปลี่ยน ให้เลือกฉากที่ไม่ต้องมีการลิงก์บัญชีหรือฉากที่เป็นจุดเข้าถึงฟังก์ชันการทำงานสำหรับผู้มาเยือนเท่านั้น

  1. คลิกไอคอนเพิ่ม สำหรับเงื่อนไข
  2. เพิ่มเงื่อนไขเพื่อทริกเกอร์โฟลว์การลิงก์บัญชีหากผู้ใช้ไม่มีข้อมูลระบุตัวตนที่เชื่อมโยง
    1. ในช่อง Enter new expression ในส่วนเงื่อนไข ให้ป้อนตรรกะต่อไปนี้ user.verificationStatus == "VERIFIED"
    2. ในส่วนการเปลี่ยน ให้เลือกโหมดระบบการลิงก์บัญชี
    3. คลิกบันทึก

เมื่อบันทึกแล้ว ระบบจะเพิ่มโหมดระบบการลิงก์บัญชีใหม่ที่ชื่อว่า <SceneName>_AccountLinking ลงในโปรเจ็กต์

ปรับแต่งฉากการลิงก์บัญชี

  1. เลือกโหมดระบบการลิงก์บัญชีในส่วนฉาก
  2. คลิกส่งพรอมต์ แล้วเพิ่มประโยคสั้นๆ เพื่ออธิบายให้ผู้ใช้ทราบว่าทำไมการดำเนินการจึงจำเป็นต้องเข้าถึงข้อมูลประจำตัว (เช่น "เพื่อบันทึกค่ากำหนดของคุณ")
  3. คลิกบันทึก

  1. ในส่วนเงื่อนไข ให้คลิกหากผู้ใช้ลิงก์บัญชีสำเร็จแล้ว
  2. กำหนดค่าว่าขั้นตอนควรดำเนินการอย่างไรหากผู้ใช้ตกลงที่จะลิงก์บัญชี เช่น เรียกใช้เว็บฮุคเพื่อประมวลผลตรรกะทางธุรกิจที่กำหนดเองที่จำเป็น แล้วเปลี่ยนกลับไปยังฉากที่สร้างขึ้น
  3. คลิกบันทึก

  1. คลิกหากผู้ใช้ยกเลิกหรือปิดการลิงก์บัญชีในส่วนเงื่อนไข
  2. กำหนดค่าว่าขั้นตอนควรดำเนินการอย่างไรหากผู้ใช้ไม่ตกลงที่จะลิงก์บัญชี เช่น ส่งข้อความตอบรับและเปลี่ยนเส้นทางไปยังฉากที่มีฟังก์ชันการทำงานที่ไม่ต้องใช้การลิงก์บัญชี
  3. คลิกบันทึก

  1. ในส่วนเงื่อนไข ให้คลิกหากระบบหรือเครือข่ายเกิดข้อผิดพลาด
  2. กำหนดค่าว่าขั้นตอนควรดำเนินการอย่างไรหากดำเนินการลิงก์บัญชีไม่สำเร็จเนื่องจากข้อผิดพลาดของระบบหรือเครือข่าย เช่น ส่งข้อความตอบรับและเปลี่ยนเส้นทางไปยังฉากที่มีฟังก์ชันการทำงานที่ไม่ต้องใช้การลิงก์บัญชี
  3. คลิกบันทึก

จัดการคำขอเข้าถึงข้อมูล

หากคำขอ Assistant มีโทเค็นเพื่อการเข้าถึง ให้ตรวจสอบก่อนว่าโทเค็นเพื่อการเข้าถึงถูกต้องและไม่หมดอายุ จากนั้นให้ดึงข้อมูลบัญชีผู้ใช้ที่เชื่อมโยงกับโทเค็นนั้นจากฐานข้อมูลบัญชีผู้ใช้