使用https将Dropbox OAuth回调到Mule

时间:2015-10-15 16:00:23

标签: oauth mule dropbox-api

Dropbox要求回调URL通过HTTPS(不使用localhost时)。

将Mule 3.6.0与最新的Dropbox连接器一起使用时,回调默认为http - 因此仅适用于localhost。对于制作,我需要使用https进行OAuth舞蹈。

指定https回调网址的正确方法是什么?

我试过了:

  <https:connector name="connector.http.mule.default">
    <https:tls-key-store path="${ssl.certfile}" keyPassword="${ssl.keyPass}" storePassword="${ssl.storePass}"/>
  </https:connector>

  <dropbox:config name="Dropbox" appKey="${dropbox.appKey}" appSecret="${dropbox.appSecret}" doc:name="Dropbox">
    <dropbox:oauth-callback-config domain="production.mydomain.com"  path="callback" />
  </dropbox:config>

但它错了:

Endpoint scheme must be compatible with the connector scheme. Connector is: "https", endpoint is "http://production.mydomain.com:8052/callback"

1 个答案:

答案 0 :(得分:0)

以下我最终解决了这个问题:

<https:connector name="connector.http.mule.default"  doc:name="HTTP-HTTPS">
  <https:tls-key-store path="${ssl.certfile}" keyPassword="${ssl.keyPass}" storePassword="${ssl.storePass}"/>
</https:connector>

<dropbox:config name="Dropbox" appKey="${dropbox.appKey}" appSecret="${dropbox.appSecret}" doc:name="Dropbox">
  <dropbox:oauth-callback-config domain="myserver.domain.com"  path="callback" connector-ref="connector.http.mule.default" localPort="8052" remotePort="8052"/>
</dropbox:config>

这适用于localhost,但如果你需要回调去localhost以外的其他东西(例如myserver.domain.com)

查看mule.log,您可以看到连接器绑定到localhost(127.0.0.0),尽管配置指向:

domain="myserver.domain.com"

日志条目:

INFO  ... Attempting to register service with name: Mule.Ops:type=Endpoint,service="DynamicFlow-https://localhost:8052/callback",connector=connector.http.mule.default,name="endpoint.https.localhost.8052.callback"
INFO  ... Registered Endpoint Service with name: Mule.Ops:type=Endpoint,service="DynamicFlow-https://localhost:8052/callback",connector=connector.http.mule.default,name="endpoint.https.localhost.8052.callback"
INFO  ... Registered Connector Service with name Mule.Ops:type=Connector,name="connector.http.mule.default.1"

解决方法是强制Mule监听0.0.0.0以获取将localhost定义为端点的连接器。

在wrapper.conf中设置

wrapper.java.additional.x=-Dmule.tcp.bindlocalhosttoalllocalinterfaces=TRUE