使用OAuth2的Mule HTTP请求配置

时间:2015-06-03 07:48:08

标签: oauth-2.0 mule

我正在尝试使用HTTP请求连接器上的OAuth2。它始终抛出以下异常:

SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'oauth2:authorization-code-grant-type'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/http":abstract-http-request-authentication-provider, "http://www.mulesoft.org/schema/mule/tcp":client-socket-properties, "http://www.mulesoft.org/schema/mule/tls":context, "http://www.mulesoft.org/schema/mule/http":raml-api-configuration, "http://www.mulesoft.org/schema/mule/http":proxy, "http://www.mulesoft.org/schema/mule/http":ntlm-proxy}' is expected

这是我的配置:

<http:request-config name="SF_Authorize_Configuration" protocol="HTTPS" host="${login.host}" basePath="${oauth2.url}" port="80" doc:name="Authorize Configuration" >
    <oauth2:authorization-code-grant-type clientId="my_client_id" clientSecret="my_client_secret" redirectionUrl="http://localhost:8081/oauth2callback">
        <oauth2:authorization-request authorizationUrl="https://my.api.com/services/oauth2/authorize" localAuthorizationUrl="http://localhost:8082/authorization" scopes="access_user_details, read_user_files">
        </oauth2:authorization-request>
        <oauth2:token-request tokenUrl="https://my.api.com/services/oauth2/token"/>
    </oauth2:authorization-code-grant-type>
</http:request-config>

2 个答案:

答案 0 :(得分:-1)

这意味着您尚未为xml标记提供xml命名空间。

如果您尚未使用UI创建此项,请使用该设计创建,然后您可以通过替换它来复制并粘贴您的特定标记。

编辑回答,

API套件对我来说类似。我重新安装了Studio(再次解压缩)。这可能会奏效。

答案 1 :(得分:-1)

我遇到了同样的问题。它通过在start mule标记处添加oauth2名称空间来解决,例如:

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
...
xmlns:oauth2="http://www.mulesoft.org/schema/mule/oauth2"
http://www.mulesoft.org/schema/mule/oauth2 
...
>