我的要求是使用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 保护的调用。请建议。
如果您分享您的连接器代码将会有所帮助。
但是,如果您使用客户端凭据流,则使用 @OAuth2 注释可能不是最佳选择,因为这使用 HTTP GET 重定向到服务提供商。
由于此授予类型不需要重定向或回调,因此通常您只需将凭据作为基本身份验证或在 POST 正文中传递到令牌端点。
您最好使用 Devkit 的连接管理功能并使用 http 客户端调用您的令牌端点并将令牌端点存储在 @Connect 方法中:
http://www.mulesoft.org/documentation/display/34X/Implementing+Connection+Management http://www.mulesoft.org/documentation/display/34X/Implementing+Connection+Management
private String token;
@Connect
public void connect(@ConnectionKey String clientKey, @Password String clientSecret)
throws ConnectionException
{
//HTTP client to call token endpoint:
//curl -u TestClient:TestSecret https://api.mysite.com/token -d 'grant_type=client_credentials'
this.token = "extract from response"
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)