アカウントのリンク解除

リンク解除は、プラットフォームまたは Google から開始できます。どちらでもリンクの状態が一致して表示されるようにすると、ユーザー エクスペリエンスが向上します。Google アカウントのリンクでは、トークン失効エンドポイントまたはクロスアカウント保護機能のサポートは任意です。

アカウントのリンクは、次のいずれかの理由で解除される可能性があります。

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

ユーザーが Google からのリンク解除をリクエストした

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

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

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

リスクとインシデントの共有と連携(RISC)を実装して、ユーザーのアカウントのリンク ステータスの変更を 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).