Friday, 19 September 2014

Authorization in the ESB connector for toodledo API




Hi all, We got a problem when developing a WSO2 ESB connector for Todledo API. Our access token is expiring after 2 hours and we need to use the refresh token to get a new access token. But our refresh token also expiring after 30 days. Once we get the access token through the operation "getAccessToken", we need to use it in all other operations. API doc says that we need to give the token as a parameter for every operation. How can we use the same token for every operation? Is there any possible way to do this? One suggestion was to use a registry to store the token when it is generated. We tried setting the token as a header in "getAccessToken" and reading it from the other operations. But it didn't work. Below is how we tried it.



getAccessToken operation



<filter source="$axis2:HTTP_SC" regex="[2][0][0]">
<then>
<property name="access_token" expression="json-eval($.access_token)" />
<header name="AUTHORIZATION" expression="get-property('accessToken')" scope="transport"/>
</then>


addingFolders operation



payloadFactory media-type="xml">
<format>
<xform>
<name>$1</name>
<private>$2</private>
</xform>
</format>
<args>
<arg expression="$func:name" />
<arg expression="$func:private" />
<arg expression="get-property('transport', 'AUTHORIZATION')" />
</args>

No comments:

Post a Comment