การยกเลิกการลิงก์อาจเริ่มจากแพลตฟอร์มของคุณหรือ Google และการแสดงสถานะลิงก์ที่สอดคล้องกันในทั้ง 2 แพลตฟอร์มจะช่วยให้ผู้ใช้ได้รับประสบการณ์ที่ดีที่สุด ระบบรองรับปลายทางการเพิกถอนโทเค็นหรือการป้องกันแบบครอบคลุมหลายบริการสําหรับการลิงก์บัญชี Google หรือไม่ก็ได้
บัญชีอาจยกเลิกการลิงก์ได้โดยการดำเนินการอย่างใดอย่างหนึ่งต่อไปนี้
- คำขอของผู้ใช้จาก
- การตั้งค่าแอปพลิเคชันของ Google หรือบัญชี Google
- แพลตฟอร์มของคุณ
- ต่ออายุโทเค็นการรีเฟรชที่หมดอายุไม่สำเร็จ
- กิจกรรมอื่นๆ ที่คุณหรือ Google เป็นผู้เริ่ม เช่น การระงับบัญชีโดยบริการตรวจจับการละเมิดและภัยคุกคาม
ผู้ใช้ขอให้ยกเลิกการลิงก์จาก Google
การยกเลิกการลิงก์บัญชีที่เริ่มต้นผ่านบัญชี Google หรือแอปของผู้ใช้จะลบโทเค็นการเข้าถึงและโทเค็นรีเฟรชที่ออกก่อนหน้านี้ นำความยินยอมของผู้ใช้ออก และเรียกใช้ปลายทางการเพิกถอนโทเค็น (ไม่บังคับ) หากคุณเลือกใช้
ผู้ใช้ขอให้ยกเลิกการลิงก์จากแพลตฟอร์มของคุณ
คุณควรระบุกลไกให้ผู้ใช้ยกเลิกการลิงก์ เช่น URL ไปยังบัญชีของตน หากคุณไม่ได้ระบุวิธีให้ผู้ใช้ยกเลิกการลิงก์ ให้ใส่ลิงก์ไปยังบัญชี Google เพื่อให้ผู้ใช้จัดการบัญชีที่ลิงก์ได้
คุณเลือกที่จะใช้ความเสี่ยงและการแชร์เหตุการณ์และการทำงานร่วมกัน (RISC) แล้วแจ้งให้ Google ทราบการเปลี่ยนแปลงสถานะการลิงก์บัญชีผู้ใช้ได้ ซึ่งจะช่วยให้ผู้ใช้ได้รับประสบการณ์การใช้งานที่ดีขึ้นเมื่อทั้งแพลตฟอร์มของคุณและ Google แสดงสถานะการลิงก์ที่เป็นปัจจุบันและสอดคล้องกันโดยไม่ต้องอาศัยการรีเฟรชหรือคำขอโทเค็นการเข้าถึงเพื่ออัปเดตสถานะการลิงก์
การหมดอายุของโทเค็น
Google จะพยายามต่ออายุโทเค็นรีเฟรชเมื่อใกล้หมดอายุเพื่อให้ผู้ใช้ได้รับประสบการณ์การใช้งานที่ราบรื่นและบริการไม่หยุดชะงัก ในบางสถานการณ์ คุณอาจต้องได้รับความยินยอมจากผู้ใช้เพื่อลิงก์บัญชีอีกครั้งเมื่อไม่มีโทเค็นรีเฟรชที่ถูกต้อง
การออกแบบแพลตฟอร์มให้รองรับโทเค็นการเข้าถึงและโทเค็นรีเฟรชที่ยังไม่หมดอายุหลายรายการจะช่วยลดเงื่อนไขการแข่งขันที่ปรากฏในการแลกเปลี่ยนข้อมูลระหว่างไคลเอ็นต์กับเซิร์ฟเวอร์ในสภาพแวดล้อมคลัสเตอร์ หลีกเลี่ยงการหยุดชะงักของผู้ใช้ และลดสถานการณ์ที่ซับซ้อนเกี่ยวกับเวลาและการจัดการข้อผิดพลาด แม้ว่าระบบจะมีความสอดคล้องกันในที่สุด แต่ทั้งโทเค็นที่ยังไม่ได้หมดอายุก่อนหน้านี้และโทเค็นที่เพิ่งออกใหม่อาจใช้งานได้เป็นระยะเวลาสั้นๆ ระหว่างการแลกเปลี่ยนการต่ออายุโทเค็นระหว่างไคลเอ็นต์กับเซิร์ฟเวอร์ และก่อนที่จะมีการซิงค์คลัสเตอร์ ตัวอย่างเช่น คำขอของ Google สำหรับบริการของคุณที่ใช้โทเค็นการเข้าถึงก่อนหน้าที่ยังไม่หมดอายุเกิดขึ้นหลังจากที่คุณออกโทเค็นการเข้าถึงใหม่ แต่ก่อนที่ Google จะได้รับและทำการซิงค์คลัสเตอร์ เราขอแนะนําให้ใช้มาตรการรักษาความปลอดภัยอื่นแทนการเปลี่ยนโทเค็นการรีเฟรช
เหตุการณ์อื่นๆ
บัญชีอาจยกเลิกการลิงก์ได้เนื่องด้วยสาเหตุอื่นๆ อีกหลายประการ เช่น ไม่มีการดําเนินการ การระงับ พฤติกรรมที่เป็นอันตราย และอื่นๆ ในกรณีเช่นนี้ แพลตฟอร์มของคุณและ Google จะจัดการบัญชีผู้ใช้และลิงก์อีกครั้งได้ดีที่สุดด้วยการแจ้งให้กันและกันทราบถึงการเปลี่ยนแปลงในบัญชีและสถานะการลิงก์
ใช้ปลายทางการเพิกถอนโทเค็นเพื่อให้ Google เรียกใช้ และแจ้ง Google เกี่ยวกับเหตุการณ์การเพิกถอนโทเค็นโดยใช้ RISC เพื่อให้แพลตฟอร์มและ Google รักษาสถานะการลิงก์บัญชีผู้ใช้ให้สอดคล้องกัน
ปลายทางการเพิกถอนโทเค็น
If you support an OAuth 2.0 token revocation endpoint, your platform can receive notifications from Google. This lets you inform users of link state changes, invalidate a token, and cleanup security credentials and authorization grants.
The request has the following form:
POST /revoke HTTP/1.1 Host: oauth2.example.com Content-Type: application/x-www-form-urlencoded client_id=GOOGLE_CLIENT_ID&client_secret=GOOGLE_CLIENT_SECRET&token=TOKEN&token_type_hint=refresh_token
Your token revocation endpoint must be able to handle the following parameters:
Revocation endpoint parameters | |
---|---|
client_id |
A string that identifies the request origin as Google. This string must be registered within your system as Google's unique identifier. |
client_secret |
A secret string that you registered with Google for your service. |
token |
The token to be revoked. |
token_type_hint |
(Optional) The type of token being revoked, either an
access_token or refresh_token . If unspecified,
defaults to access_token . |
Return a response when the token is deleted or invalid. See the following for an example:
HTTP/1.1 200 Success Content-Type: application/json;charset=UTF-8
If the token can't be deleted for any reason, return a 503 response code, as shown in the following example:
HTTP/1.1 503 Service Unavailable Content-Type: application/json;charset=UTF-8 Retry-After: HTTP-date / delay-seconds
Google retries the request later or as requested by Retry-After
.
การป้องกันแบบครอบคลุมหลายบริการ (RISC)
If you support Cross-Account Protection, your platform can notify Google when access or refresh tokens are revoked. This allows Google to inform users of link state changes, invalidate the token, cleanup security credentials, and authorization grants.
Cross-Account Protection is based on the RISC standard developed at the OpenID Foundation.
A Security Event Token is used to notify Google of token revocation.
When decoded, a token revocation event looks like the following example:
{
"iss":"http://risc.example.com",
"iat":1521068887,
"aud":"google_account_linking",
"jti":"101942095",
"toe": "1508184602",
"events": {
"https://schemas.openid.net/secevent/oauth/event-type/token-revoked":{
"subject_type": "oauth_token",
"token_type": "refresh_token",
"token_identifier_alg": "hash_SHA512_double",
"token": "double SHA-512 hash value of token"
}
}
}
Security Event Tokens that you use to notify Google of token revocation events must conform to the requirements in the following table:
Token revocation events | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
iss |
Issuer Claim: This is a URL which you host, and it's shared with Google during registration. | ||||||||||
aud |
Audience Claim: This identifies Google as the JWT recipient. It
must be set to google_account_linking . |
||||||||||
jti |
JWT ID Claim: This is a unique ID that you generate for every security event token. | ||||||||||
iat |
Issued At Claim: This is a NumericDate value
that represents the time when this security event token was created. |
||||||||||
toe |
Time of Event Claim: This is an optional
NumericDate value that represents the time at which the
token was revoked. |
||||||||||
exp |
Expiration Time Claim: Do not include this field, as the event resulting in this notification has already taken place. | ||||||||||
events |
|
For more information on field types and formats, see JSON Web Token (JWT).