作为撤消特定令牌的替代方法,您可以撤消客户端 ID 或整个开发者应用。如需了解详情,请参阅撤消和批准开发者应用密钥。与撤消单个令牌相比,撤消客户端 ID 或开发者应用会产生更广泛的影响。撤消客户端 ID 或开发者应用时,Apigee 将拒绝与该客户端 ID 或开发者应用关联的所有令牌,并且将不再为该客户端 ID 或开发者应用颁发新令牌。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-05。"],[[["\u003cp\u003eThis documentation covers token revocation and re-approval within Apigee and Apigee hybrid, focusing on the management of OAuth tokens.\u003c/p\u003e\n"],["\u003cp\u003eTokens can be revoked using either the OAuthV2 policy with the \u003ccode\u003eInvalidateToken\u003c/code\u003e operation or the RevokeOAuthV2 policy, but only opaque OAuth tokens, not JWTs.\u003c/p\u003e\n"],["\u003cp\u003eRevoking a client ID or developer app invalidates all associated tokens and prevents the issuance of new ones, while revoking a single token only impacts that specific token.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecascade\u003c/code\u003e attribute within the \u003ccode\u003eToken\u003c/code\u003e element allows for control over whether both the access token and refresh token are revoked or only the refresh token.\u003c/p\u003e\n"],["\u003cp\u003eRevoked tokens can be re-approved using the \u003ccode\u003eValidateToken\u003c/code\u003e operation of the OAuthV2 policy, making them valid again until they expire, and tokens are cached for 3 minutes, even after being revoked.\u003c/p\u003e\n"]]],[],null,["# Revoking and approving tokens\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nUnderstanding token revocation\n------------------------------\n\nIn some cases, apps are required to explicitly revoke or invalidate individual\ntokens. A typical case might be when a user logs out of an OAuth-enabled app. A revoked\ntoken will no longer be useful for authorization. After a token has been revoked, if an\napp presents that token to an API proxy, an OAuthV2 policy with an Operation of\nVerifyAccessToken will reject that token.\n| **Warning:**OAuth tokens are cached for three minutes (180 seconds); therefore, a revoked token may still succeed for up to three minutes, until its cache limit expires.\n\nThe standard for token revocation is defined by IETF RFC 7009, the [OAuth 2.0 Token Revocation\nspecification](https://tools.ietf.org/html/rfc7009).\n\nAs an alternative to revoking specific tokens, you can revoke client IDs, or entire developer\napps. See [Revoking\nand approving developer app keys](/apigee/docs/api-platform/security/oauth/revoking-and-approving-consumer-ids) for details. As compared to revoking an\nindividual token, revoking a client ID or developer app has a broader impact. When you\nrevoke a client ID or developer app, Apigee will reject all tokens associated with that\nclient ID or developer app, and will no longer issue new tokens for that client ID or\ndeveloper app.\n\nAfter revoking a token, either an access token or a refresh token, you can optionally\nre-approve that token, at any time before it expires. After re-approving the token, the\nApigee OAuthV2 policy will again accept that token for authorization, until the token\nexpires. Token expiration is independent of the approved or revoked state of the token.\nThe Apigee OAuthV2 policy with an Operation of ValidateAccessToken will accept an\naccess token only if that token is both approved (or not revoked) and not expired.\nLikewise, the Apigee OAuthV2 policy with an Operation of RefreshAccessToken will accept a\nrefresh token only if that token is both approved (or not revoked) and not expired.\n| **Note:** You cannot revoke a JWT access token. You can revoke only opaque OAuth tokens, either access tokens or refresh tokens, that have been generated by the OAuthV2 policy. While the OAuthV2 policy can generate access tokens that are of either opaque format or JWT format, you cannot revoke JWT access tokens that have been generated by the OAuthV2 policy.\n\nThere are two policies that you can use to revoke tokens:\n\n- the [OAuthV2 policy](/apigee/docs/api-platform/reference/policies/oauthv2-policy), using an `Operation` of `InvalidateToken`.\n- the [RevokeOAuthV2 policy](/apigee/docs/api-platform/reference/policies/revoke-oauth-v2-policy).\n\nThe OAuthV2 policy has the capability to revoke, and also reinstate, a single token at\na time. The RevokeOAuthV2 policy is more flexible in that it can revoke multiple tokens at\nonce, by App ID, or End User ID. The rest of this page describes using the OAuthV2 policy\nto revoke a token or to reinstate a previously revoked token.\n\nRevoking access and refresh tokens\n----------------------------------\n\n| **Warning:**OAuth tokens are cached for three minutes (180 seconds); therefore, a revoked token may still succeed for up to three minutes, until its cache limit expires.\n\nHere's an example configuration for the OAuthV2 policy that uses the InvalidateToken\nOperation. In this case, because the `cascade` attribute on the\n`Token` element is true, Apigee revokes both the access token and its\nassociated refresh token. \n\n```carbon\n \u003cOAuthV2 name=\"InvalidateToken\"\u003e\n \u003cOperation\u003eInvalidateToken\u003c/Operation\u003e\n \u003cTokens\u003e\n \u003cToken type=\"accesstoken\" cascade=\"true\"\u003erequest.queryparam.token\u003c/Token\u003e\n \u003c/Tokens\u003e\n \u003c/OAuthV2\u003e\n \n```\n\nFor more information about how the cascade flag works, see the section below on the\nAttributes for the Token element.\n\n### \\\u003cTokens\\\u003e/\\\u003cToken\\\u003e\nelement\n\nIdentifies the flow variable that specifies the token to be revoked. If developers are\nexpected to submit a revocation request using a query parameter\nnamed `access_token`, for example, the correct flow variable will\nbe: `request.queryparam.access_token`. To require the token in an HTTP header,\nfor example, set this value to `request.header.access_token`.\n\nIt is not possible to revoke an access token that is in JWT format.\nFurther, it is not possible to use the OAuthV2 policy to\nrevoke a refresh token that is associated to an access token that is in JWT\nformat. A runtime error will occur if the context variable specified here refers to\na JWT access token, or a refresh token that is associated to a JWT access token.\nYou can revoke refresh tokens associated to JWT access tokens using the [RevokeOAuthV2 policy](/apigee/docs/api-platform/reference/policies/revoke-oauth-v2-policy).\n\n### Attributes\n\n- `type` (required, string): The token type identified by the variable specified. Supported values are `accesstoken` and `refreshtoken:`\n - To revoke an access token, specify type accesstoken.\n - To revoke both the access and refresh tokens, specify type refreshtoken. When it sees type refreshtoken, Apigee assumes the token is a refresh token. If that refresh token is found, then it is revoked. If that refresh token is not found, then Apigee checks to see if it is an access token. If the access token exists, then it is revoked. \n\n **Note:** If you pass an already invalidated token to an InvalidateToken policy, the policy doesn't return an error, although you might expect it to. Such an operation has no effect.\n- `cascade` (optional, boolean, default: true) The primary use of this attribute is to revoke a refresh token without revoking its associated access token. Consider these cases:\n - Revoke a refresh token only and do not revoke its associated access token. To do this, set the \\\u003cToken\\\u003e type to `refreshtoken` and set cascade to `false`.\n - Revoke both the access token and the refresh token. To do this, set the \\\u003cToken\\\u003e type to `accesstoken`. The value of cascade can be either `true` (the default) or `false`. If you set it to `true`, then both the access token and the refresh token are revoked. If you set it to `false`, the access token is revoked, and the refresh token is unusable. See the Note below for more explanation.\n - Revoke an access token and do not revoke its associated refresh token. Not supported. See the Note below for more explanation.\n\n**Note:** For security reasons, if you revoke an\naccess token, the associated refresh token will be revoked also. Therefore, you cannot use\nthe cascade attribute to revoke only an access token. For example, if you set the \\\u003cToken\\\u003e\ntype to `accesstoken`, and set `cascade=false`, the access token is revoked\n(as expected); however, the associated refresh token is unusable. It cannot be used to refresh\nthe revoked access token. The primary use case for the cascade attribute is when you want to only\nrevoke a refresh token. In that case, set the \\\u003cToken\\\u003e type to `refreshtoken`,\nand set `cascade=false`. The refresh token will be revoked, but its associated access\ntoken will remain valid (until it expires or is revoked). For more information, see this [Community forum discussion](https://community.apigee.com/questions/5813/need-help-interpreting-cascade-on-invalidatetoken.html#comment-6763).\n\nApproving access and refresh tokens\n-----------------------------------\n\nUse the ValidateToken operation to \"re-approve\" a revoked token. That is, when you apply this\noperation, the status of the targeted access or refresh token is changed from 'revoked' to\n'approved'. You can validate any revoked token that has not already expired. \n\n```gdscript\n\u003cOAuthV2 name=\"ValidateToken\"\u003e\n \u003cOperation\u003eValidateToken\u003c/Operation\u003e\n \u003cTokens\u003e\n \u003cToken type=\"refreshtoken\" cascade=\"true\"\u003eflow.variable\u003c/Token\u003e\n \u003c/Tokens\u003e\n\u003c/OAuthV2\u003e\n```\n\n### \\\u003cTokens\\\u003e/\\\u003cToken\\\u003e\nelement\n\nIdentifies the flow variable that specifies the token to be validated. If developers are\nexpected to submit a validation request using a query parameter\nnamed `access_token`, for example, the correct flow variable will\nbe: `request.queryparam.access_token`. To require the token in an HTTP header,\nfor example, set this value to `request.header.access_token`.\n\n### Attributes\n\n- `type` (required, string) The token type identified by the variable specified. Supported values are `accesstoken` and `refreshtoken`.\n- `cascade` (optional, boolean): By default, this option is set to `true`, and causes the validation to propagate to associated tokens. So, if applied to a refresh token, its associated access token is also validated. If applied to an access token, its associated refresh token is also validated. If you set this to `false`, then only the specified access or refresh token is validated."]]