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

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

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

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

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

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

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

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

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

トークンの有効期限

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

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

その他のイベント

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

Google が呼び出すトークン取り消しエンドポイントを実装し、RISC を使用してトークン取り消しイベントを Google に通知し、プラットフォームと 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
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).