DeleteOAuthV2Info 政策

本页面适用于 ApigeeApigee Hybrid

查看 Apigee Edge 文档。

政策图标

内容

删除指定的 OAuth V2 授权代码或访问令牌。

此政策是一项可扩展政策,使用此政策可能会影响费用或使用情况,具体取决于您的 Apigee 许可。如需了解政策类型和使用情况影响,请参阅政策类型

示例

删除访问令牌

以下是用于删除 OAuth 2.0 访问令牌的示例政策。以下示例通过查找名为 access_token 的标头,在请求消息中删除访问令牌。

<DeleteOAuthV2Info name="DeleteAccessToken">
     <AccessToken ref="request.header.access_token"></AccessToken>
</DeleteOAuthV2Info>

删除 Auth 代码

下面是一个示例政策,用于删除 OAuth 2.0 授权代码。以下示例通过查找名为 code 的查询参数来查找要在请求消息中删除的 auth 代码。

<DeleteOAuthV2Info name="DeleteAuthCode">
     <AuthorizationCode ref="request.queryparam.code"></AuthorizationCode>
</DeleteOAuthV2Info>

元素参考

元素参考描述了 DeleteOAuthV2Info 政策的元素和属性。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DeleteOAuthV2Info async="false" continueOnError="false" enabled="true" name="DeleteOAuthV2Info-1">    
    <DisplayName>Delete OAuth v2.0 Info 1</DisplayName>
    <AccessToken ref={some-variable}></AccessToken>
    <!--<AuthorizationCode ref={some-variable}></AuthorizationCode>-->
    <Attributes/>
</DeleteOAuthV2Info

<DeleteOAuthV2Info> 属性

<DeleteOAuthV2Info async="false" continueOnError="false" enabled="true" name="Delete-OAuth-v20-Info-1">
属性 说明 默认 Presence
async

设置为 true 以指定政策应在与请求/响应流运行的池不同的线程池中运行。默认值为 false

此设置仅用于内部优化。

false 可选
continueOnError

大多数政策会在发生故障时返回错误。将此属性设置为 true 后,流执行会失败。

false 可选
已启用 确定是否强制执行政策。如果设置为 false,则政策会“关闭”,并且不会强制执行(即使政策仍附加到某个流)。 true 可选
name

政策的内部名称。此名称在 Step 元素中引用,以便将政策附加到流。

注意:您可以在名称中使用的字符仅限于:A-Z0-9._\-$ %。Apigee 界面会实施其他限制,例如自动移除非字母数字字符。

不适用 必需

<AccessToken> 元素

标识要删除的访问令牌所在的变量。例如,如果访问令牌作为查询参数“access_token”附加到请求消息,请指定 request.queryparam.access_token。您可以使用引用令牌的任何有效变量。或者,传入字面令牌字符串(罕见大小写)。

 <AccessToken ref="request.queryparam.access_token"></AccessToken>
默认: 不适用
状态: 必须提供 <AccessToken><AuthorizationCode>
类型: 字符串

属性

属性 说明 默认 Presence
ref

访问令牌变量。通常从流变量检索。例如 request.header.tokenrequest.queryparam.token

不适用 可选

<AuthorizationCode> 元素

标识要删除的授权代码所在的变量。例如,如果 auth 代码作为查询参数(名为“code”)附加到请求消息,请指定 request.queryparam.code。您可以使用引用令牌的任何有效变量。或者,传入字面令牌字符串(罕见大小写)。

 <AuthorizationCode ref="request.queryparam.code"></AuthorizationCode>
默认: 不适用
状态: 必须提供 <AccessToken><AuthorizationCode>
类型: 字符串

属性

属性 说明 默认 Presence
ref

访问令牌变量。通常从流变量检索。例如 request.header.coderequest.queryparam.code

不适用 可选

<DisplayName> 元素

在 Apigee 界面代理编辑器中,用自然语言名称给政策加标签。如果省略,则使用政策名称属性。

<DisplayName>DeleteOAuthV2Info 1</DisplayName>
默认: 政策的 name 属性的值。
状态: 可选
类型: 字符串

错误参考信息

This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

These errors can occur when the policy executes.

Fault code HTTP status Cause
steps.oauth.v2.invalid_access_token 401 The access token sent to the policy is invalid.
steps.oauth.v2.invalid_request-authorization_code_invalid 401 The authorization code sent to the policy is invalid.
steps.oauth.v2.InvalidAPICallAsNoApiProductMatchFound 401 Please see Oauth2.0 Access Token Verification throws "Invalid API call as no apiproduct match found" error for information about troubleshooting this error.

Deployment errors

Refer to the message reported in the UI for information about deployment errors.

Fault variables

These variables are set when this policy triggers an error at runtime.

Variables Where Example
fault.name="fault_name" fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. fault.name = "invalid_access_token"
oauthV2.policy_name.failed policy_name is the user-specified name of the policy that threw the fault. oauthV2.DeleteTokenInfo.failed = true
oauthV2.policy_name.fault.name policy_name is the user-specified name of the policy that threw the fault. oauthV2.DeleteTokenInfo.fault.name = invalid_access_token
oauthv2.policy_name.fault.cause policy_name is the user-specified name of the policy that threw the fault. oauthV2.DeleteTokenInfo.cause = Invalid Access Token

Example error response

{
  "fault": {
    "faultstring": "Invalid Access Token",
    "detail": {
      "errorcode": "keymanagement.service.invalid_access_token"
    }
  }
}

Example fault rule

<faultrule name="VariableOfNonMsgType"></faultrule><FaultRule name="DeleteOAuthV2Info_Faults">
    <Step>
        <Name>AM-InvalidTokenResponse</Name>
    </Step>
    <Condition>(fault.name = "invalid_access_token")</Condition>
</FaultRule>

架构

每种政策类型均由 XML 架构 (.xsd) 定义。GitHub 提供了政策架构作为参考。

相关主题