排解基本驗證政策部署錯誤

您正在查看 ApigeeApigee Hybrid 說明文件。
查看 Apigee Edge 說明文件。

UserNameRequired

錯誤訊息

透過 Apigee UI 或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: Username element must be present for operation operation.

錯誤訊息示例

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: Username element must be present for Encode operation.

螢幕截圖範例

原因

如果在 BasicAuthentication 政策中未定義 <User> 元素,API Proxy 的部署作業就會失敗。編碼和解碼作業都必須使用 <User> 元素。

診斷

  1. 檢查 API Proxy 中使用的所有 BasicAuthentication 政策。如果有任何政策未指定 <User> 元素,就是錯誤的原因。在 BasicAuthentication 政策中,如果要進行編碼或解碼作業,就必須使用 <User> 元素。

    下方的 BasicAuthentication 政策範例用於編碼作業,但未定義 <User> 元素:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Encode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <Password ref="BasicAuth.credentials.password"/>
      <AssignTo createNew="false">request.header.Authorization</AssignTo>
    </BasicAuthentication>
    

    部署失敗,並顯示以下錯誤:

    BasicAuthenticationPolicy: Username element must be present for Encode operation.
    

解決方法

請確認 <User> 元素已在 BasicAuthentication 政策中定義,以便執行編碼或解碼作業。

如要修正上述範例,請在政策中加入 <User> 元素,如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

PasswordRequired

錯誤訊息

透過 Apigee UI 或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: Password element must be present for operation operation.

錯誤訊息示例

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: Password element must be present for Encode operation.

螢幕截圖範例

原因

如果在 BasicAuthentication 政策中未定義 <Password> 元素,API Proxy 的部署作業就會失敗。編碼和解碼作業都必須使用 <Password> 元素。

診斷

  1. 檢查 API Proxy 中使用的所有 BasicAuthentication 政策。如果有任何政策未定義 <Password> 元素,則該政策會導致錯誤。在 BasicAuthentication 政策中,<Password> 元素是編碼或解碼作業的必要元素。

    下方的 BasicAuthentication 政策範例用於編碼作業,但未定義 <Password> 元素:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Encode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <User ref="BasicAuth.credentials.username"/>
      <AssignTo createNew="false">request.header.Authorization</AssignTo>
    </BasicAuthentication>
    

    部署失敗,並顯示以下錯誤:

    BasicAuthenticationPolicy: Password element must be present for Encode operation.
    

解決方法

請確認 <Password> 元素已在 BasicAuthentication 政策中定義,以便執行編碼或解碼作業。

如要修正上述範例,請在政策中加入 <Password> 元素,如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

AssignToRequired

錯誤訊息

透過 Apigee UI 或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: AssignTo element must be present for operation operation.

錯誤訊息示例

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: AssignTo element must be present for Encode operation.

螢幕截圖範例

原因

如果在 BasicAuthentication 政策中未定義 <AssignTo> 元素,API Proxy 的部署作業就會失敗。編碼和解碼作業都必須使用 <AssignTo> 元素。

診斷

  1. 檢查 API Proxy 中使用的所有 BasicAuthentication 政策。如果有任何政策未定義 <AssignTo> 元素,則該政策會導致錯誤。針對編碼和解碼作業,必須在 BasicAuthentication 政策中定義 <AssignTo> 元素。

    下方的 BasicAuthentication 政策範例用於編碼作業,但未定義 <AssignTo> 元素:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Encode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <User ref="BasicAuth.credentials.username"/>
      <Password ref="BasicAuth.credentials.password"/>
    </BasicAuthentication>
    

    部署失敗,並顯示以下錯誤:

    BasicAuthenticationPolicy: AssignTo element must be present for Encode operation.
    

解決方法

請確認 <AssignTo> 元素已在 BasicAuthentication 政策中定義,以便執行編碼或解碼作業。

如要修正上述範例,請在政策中加入 <AssignTo> 元素,如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

SourceRequired

錯誤訊息

透過 Apigee UI 或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: Source element must be present for Decode operation.

錯誤訊息示例

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: Source element must be present for Decode operation.

螢幕截圖範例

原因

如果在用於解碼作業的 BasicAuthentication 政策中未定義 <Source> 元素,API Proxy 的部署作業就會失敗。如果 BasicAuthentication 政策中將 <Operation> 指定為 Decode,則必須使用 <Source> 元素。

診斷

  1. 檢查 API Proxy 中使用的所有 BasicAuthentication 政策。如果有任何政策未定義 <Source> 元素,且 <Operation> 元素定義為 Decode,則這就是錯誤的原因。如果 BasicAuthentication 政策中將 <Operation> 指定為 Decode,則必須使用 <Source> 元素。

    下方的 BasicAuthentication 政策範例用於 Decode 作業,但未定義 <Source> 元素:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Decode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <User ref="BasicAuth.credentials.username"/>
      <Password ref="BasicAuth.credentials.password"/>
      <AssignTo createNew="false">request.header.Authorization</AssignTo>
    </BasicAuthentication>
    

    部署失敗,並顯示以下錯誤:

    BasicAuthenticationPolicy: Source element must be present for Decode operation.
    

解決方法

請確認在使用 Decode 作業時,<Source> 元素已在 BasicAuthentication 政策中定義。

如要修正上述範例,請在政策中加入 <Source> 元素,如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Decode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
    <Source>request.header.Authorization</Source>
</BasicAuthentication>