我的要求是使用OAuth2的client_credentials grant_type来获取Mule中的访问令牌 . 我想实现启用OAuth的自定义连接器 . 我无法使用以下配置实现它:
<XXX-auth2:config name="TestAuth" consumerKey="abc" consumerSecret="1234" doc:name="TestAuth">
<XXX-auth2:oauth-callback-config domain="localhost" localPort="8082" path="callback" remotePort="8082" async="false"/>
</XXX-auth2:config>
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="testoauth" doc:name="HTTP" />
<XXX-auth2:authorize config-ref="TestAuth" doc:name="TestAuth"/>
<logger message="Test Auth output:#[flowVars['tokenId']]" level="INFO" doc:name="Logger"/>
</flow>
我的要求是从批处理作业管理OAuth保护的调用 . 请建议 .
1 回答
如果您共享连接器代码,将会有所帮助 .
但是,如果您使用的是客户端凭据流,则使用@ OAuth2注释可能无法实现,因为这会使用HTTP GET重定向到服务提供者 .
由于此授权类型不需要重定向或回调,因此通常只需将凭据作为基本身份验证或POST主体传递给令牌 endpoints .
您最好使用Devkit的连接管理功能,并使用http客户端调用令牌 endpoints 并将令牌 endpoints 存储在@Connect方法中:
http://www.mulesoft.org/documentation/display/34X/Implementing+Connection+Management