我测试了Twitter和LinkedIn,我似乎最终能够使这些工作正常,但我找不到足够的材料来让Google连接器工作。使用Google日历连接器时,我尝试使用 - #[flowVars['tokenId']]
收集令牌,但值始终为null
。难道我做错了什么?有人可以帮忙吗?
谢谢,
灰。
答案 0 :(得分:1)
回答了我自己的问题,其他任何人都在努力解决同样的问题 -
管理OAuth令牌(可选)
配置ObjectStore
为了保持数据持久性,您需要将其存储在某个地方,建议您使用ObjectStore。安装ObjectStore连接器。在您的应用程序中像这样配置:
<objectstore:config name="ObjectStore" doc:name="ObjectStore" />
授权后存储令牌
授权舞蹈完成后,您正在调用的服务的accessTokenId可用作名为OAuthAccessTokenId的流变量。您必须保留此ID,以便在将来调用连接器时使用它。此示例显示如何在密钥accessTokenId。
下将此变量存储到ObjectStore中<flow name="authorize-google" doc:name="authorize-google">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="authorize" doc:name="HTTP"/>
<google-contacts:authorize config-ref="Google_Contacts" doc:name="Authorize GContacts"/>
<objectstore:store config-ref="ObjectStore" key="accessTokenId" value-ref="#[flowVars['OAuthAccessTokenId']]" overwrite="true" doc:name="ObjectStore"/>
</flow>
使用您的访问令牌
对连接器的任何调用都必须从ObjectStore加载访问令牌并引用它。此示例显示从ObjectStore加载它并检查它是否已设置,然后继续。
<enricher target="#[flowVars['accessTokenId']]" doc:name="Message Enricher">
<objectstore:retrieve config-ref="ObjectStore" key="accessTokenId" defaultValue-ref="#['']" doc:name="Get AccessToken"/>
</enricher>
<expression-filter expression="#[flowVars['accessTokenId'] != '']" doc:name="Is Access Token Set"/>
一旦accessTokenId可用作流变量,您就可以在连接器操作中引用它:
<google-contacts:get-contacts config-ref="Google_Contacts" accessTokenId="#[flowVars['accessTokenId']]" />
此处有更多详情 - http://www.mulesoft.org/documentation/display/34X/Using+a+Connector+to+Access+an+OAuth+API
下面是工作室的样子 - http://imgur.com/DtLodel
谢谢,
灰。