アカウントのリンクを解除

リンクの解除はプラットフォームまたは Google から開始される場合があり、どちらの場合も一貫したリンク状態を表示することでユーザー エクスペリエンスを最大限に高めることができます。Google アカウントのリンク設定では、トークン取り消しエンドポイントやクロスアカウント保護は任意です。

次のいずれかによってアカウントのリンクが解除されることがあります。

  • ユーザーからのリクエスト:
    • Google アプリケーションまたは Google アカウントの設定
    • 使用するプラットフォーム
  • 期限切れの更新トークンを更新できませんでした
  • お客様または Google が開始したその他のイベント。たとえば、不正行為や脅威検出サービスによるアカウントの強制停止などです。

ユーザーが Google とのリンクを解除するようリクエストしました

ユーザーの Google アカウントまたはアプリからアカウントのリンク解除が開始されると、以前に発行したアクセス トークンと更新トークンが削除され、ユーザーの同意が削除されます。また、必要に応じてトークン取り消しエンドポイントを呼び出すこともできます。

ユーザーがプラットフォームからのリンク解除をリクエストしました

ユーザーがアカウントのリンクを解除するためのメカニズム(アカウントへの URL など)を用意する必要があります。リンクを解除する方法がユーザーにない場合は、Google アカウントへのリンクを含めて、ユーザーがリンクされたアカウントを管理できるようにします。

リスクとインシデントの共有とコラボレーション(RISC)を実装し、ユーザー アカウントのリンク ステータスの変更を Google に通知することもできます。これにより、更新状態やアクセス トークンのリクエストを使用してリンク状態を更新する必要なく、プラットフォームと Google の両方で最新の一貫したリンク ステータスを表示するユーザー エクスペリエンスを向上させることができます。

トークンの有効期限

スムーズなユーザー エクスペリエンスを実現し、サービスの中断を避けるために、Google は有効期間の終了間近で更新トークンの更新を試みます。状況によっては、有効な更新トークンが利用できない場合に、アカウントの再リンクに対するユーザーの同意が必要になることがあります。

有効期限のない複数のアクセス トークンと更新トークンをサポートするようにプラットフォームを設計すると、クラスタ環境間のクライアントとサーバーの交換における競合状態を最小限に抑え、ユーザーの中断をなくし、複雑なタイミングとエラー処理のシナリオを最小限に抑えることができます。結果整合性が保たれますが、まだ発行されていない期限切れのトークンは、クライアント サーバー トークンの更新中も、クラスタの同期前も、しばらくの間使用される場合があります。たとえば、以前の期限切れでないアクセス トークンを使用する Google サービスへの Google リクエストは、新しいアクセス トークンを発行した直後、かつ受信とクラスタ同期が Google で行われる前に行われます。更新トークンのローテーションに代わるセキュリティ対策をおすすめします。

その他のイベント

アカウントのリンクは、非アクティブ、停止、悪意のある動作など、その他のさまざまな理由でリンク解除できます。このようなシナリオでは、プラットフォームと Google は、ユーザー アカウントとリンク状態の変更を互いに通知することで、ユーザー アカウントを再管理して再リンクすることができます。

Google が呼び出すトークン取り消しエンドポイントを実装し、RISC を使用してトークン取り消しイベントを Google に通知し、プラットフォームと Google が一貫したユーザー アカウントのリンク状態を維持できるようにします。

トークン失効エンドポイント

如果您支持OAuth 2.0令牌吊销终结点,则您的平台可以接收来自Google的通知。这使您可以通知用户链接状态更改,使令牌无效以及清理安全凭证和授权授予。

该请求具有以下形式:

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

您的令牌吊销终结点必须能够处理以下参数:

撤销端点参数
client_id一个字符串,用于将请求来源标识为Google。此字符串必须在您的系统中注册为Google的唯一标识符。
client_secret您在Google注册的用于服务的秘密字符串。
token要撤消的令牌。
token_type_hint (可选)要撤消的令牌类型,可以是access_tokenrefresh_token 。如果未指定,则默认为access_token

当令牌被删除或无效时返回响应。请参见以下示例:

HTTP/1.1 200 Success
Content-Type: application/json;charset=UTF-8

如果由于某种原因无法删除令牌,请返回503响应代码,如以下示例所示:

HTTP/1.1 503 Service Unavailable
Content-Type: application/json;charset=UTF-8
Retry-After: HTTP-date / delay-seconds

Google稍后或按照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
Security Events Claim: This is a JSON object, and must include only a single token revocation event.
subject_type This must be set to oauth_token.
token_type This is the type of token being revoked, either access_token or refresh_token.
token_identifier_alg This is the algorithm used to encode the token, and it must be hash_SHA512_double.
token This is the ID of the revoked token.

For more information on field types and formats, see JSON Web Token (JWT).