简体   繁体   English

wso2 esb连接器如何在集群环境中共享访问令牌

[英]wso2 esb connector how to share accesstoken in cluster environment

I am working on a project by using wso2 esb as integration bus, and esb is running on cluster environment. 我正在使用wso2 esb作为集成总线来进行项目,而esb在集群环境中运行。 Now ESB will connect to third party application (like salesforce) via connector, and salesforce will issue accesstoken to esb connector. 现在,ESB将通过连接器连接到第三方应用程序(如salesforce),而salesforce将向esb连接器发出访问令牌。 There are two issues here: 这里有两个问题:

1 how to refresh access token periodically 1如何定期刷新访问令牌

the accesstoken will be expired every 2 hours, so how to avoid a request is invalid by expired accesstoken (in general, system needs to get a new token every 2 hours). 该访问令牌将每2小时过期一次,因此如何避免由于过期的访问令牌而使请求无效(通常,系统需要每2小时获取一个新令牌)。 I didn't see this configuration in ESB sample. 我在ESB示例中没有看到此配置。

2 how to share access token in cluster environment 2如何在集群环境中共享访问令牌

WSO2 Salesforce REST connector is released in store with supporting token refreshing and it will support to share access token in cluster environment. WSO2 Salesforce REST连接器在商店中发布,支持令牌刷新,它将支持在群集环境中共享访问令牌。

<salesforcerest.init>
    <accessToken>{$ctx:accessToken}</accessToken>
    <apiUrl>{$ctx:apiUrl}</apiUrl>
    <clientId>{$ctx:clientId}</clientId>
    <clientSecret>{$ctx:clientSecret}</clientSecret>
    <refreshToken>{$ctx:refreshToken}</refreshToken>
    <hostName>{$ctx:hostName}</hostName>
    <apiVersion>{$ctx:apiVersion}</apiVersion>
    <registryPath>{$ctx:registryPath}</registryPath>
    <intervalTime>{$ctx:intervalTime}</intervalTime>
 <salesforcerest.init>

In above configuration, intervalTime is in milliseconds to check the access token validity. 在上述配置中,intervalTime以毫秒为单位来检查访问令牌的有效性。 For example, Salesforce access token is expired in 2 hours. 例如,Salesforce访问令牌在2小时后过期。 So you need to give the intervalTime in milliseconds less than 2 hours. 因此,您需要将间隔时间(以毫秒为单位)指定为少于2小时。 Once the token is expired, when you call the connector method, it will check the access token validity. 令牌过期后,当您调用连接器方法时,它将检查访问令牌的有效性。 If it is expired, the connector will refresh the access token using refresh token and save it in registry. 如果过期,则连接器将使用刷新令牌刷新访问令牌并将其保存在注册表中。 In above configuration, you can give the registry path. 在上述配置中,您可以提供注册表路径。 if you don't pass registry path in the configuration, the connector will save the access token in default registry path. 如果您未在配置中传递注册表路径,则连接器会将访问令牌保存在默认注册表路径中。

In WSO2 ESB deployments config registry is usually mounted and shared among cluster nodes so you can share access token in cluster environment 在WSO2 ESB部署中,通常会在群集节点之间安装并共享配置注册表,因此您可以在群集环境中共享访问令牌

You can refer the wso2 documentation and the blog for the connector configuration. 您可以参考wso2 文档博客来了解连接器配置。 The Connector zip file can be downloaded from here . 可以从此处下载连接器zip文件。 Go to the link and click the 'download connector' button and follow the documentation for the configuration. 转到链接,然后单击“下载连接器”按钮,然后按照文档进行配置。

In above configuration you must give the registry path as "connectors/"connectorname"". 在以上配置中,您必须将注册表路径指定为“ connectors /” connectorname””。 If you are like to get the accessToken from username password flow you don't need to worry about the accessToken expiration(Only for Salesforce REST connector). 如果您想从用户名密码流中获取accessToken,则无需担心accessToken过期(仅适用于Salesforce REST连接器)。 You can follow here about username password flow. 您可以在此处关注用户名密码流。 In other cases like Google API connectors(Example Gmail) you don't need to give the registry path because the connector itself create a registry location to store the accessToken. 在其他情况下,例如Google API连接器(例如Gmail),您无需提供注册表路径,因为连接器本身会创建一个注册表位置来存储accessToken。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM