---------- Forwarded message ---------- From: Dinithi De Silva <dinit...@wso2.com> Date: Mon, Sep 8, 2014 at 5:34 PM Subject: Generating Basic Authentication header using the code To: d...@wso2.com, WSO2 Training Group <training-gr...@wso2.com>
Hi all, I am developing an ESB connector for ToodleDo API v3. To get the access token, I need to pass the Basic Authentication header (using client id and secret) with the Authentication code. I used Advanced REST client to get the access token and it was successful. I can construct the header using the REST client. I need to know how to implement it from the code. Do I need to send the encoded client id and secret to generate the header? Below is the code that I have tried. Here I hard coded the client id and secret and tested. But it did not work. <sequence> <header name="Content-Type" value="application/x-www-form-urlencoded" scope="transport" /> <header name="Authorization" key="Authorization" value="'Authorization : Basic ' + base64(clientID + ':' + clientSecret)" /> <property name="messageType" value="application/x-www-form-urlencoded" scope ="axis2" /> <property name="DISABLE_CHUNKING" value="true" scope="axis2" /> <property name="uri.var.code" expression="$func:code" /> <property name=" uri.var.vers" expression="$func:vers" /> <property name="uri.var.os" expression="$func:os" /> <property name="uri.var.device" expression=" $func:device" /> <payloadFactory media-type="xml"> <format> <xform> < grant_type>authorization_code</grant_type> <code>$1</code> <vers>$2</vers> < os>$3</os> <device>$4</device> </xform> </format> <args> <arg expression=" get-property('uri.var.code')" /> <arg expression=" get-property('uri.var.vers')" /> <arg expression="get-property('uri.var.os') " /> <arg expression="get-property('uri.var.device')" /> </args> </ payloadFactory> <call> <endpoint> <http method="post" uri-template=" https://api.toodledo.com/3/account/token.php" /> </endpoint> </call> <filter source="$axis2:HTTP_SC" regex="[2][0][0]"> <then> <property name=" access_token" expression="json-eval($.access_token)" /> <header name=" Authorization" expression="fn:concat('Bearer ',get-property('access_token')) " scope="transport" /> </then> </filter> </sequence> Thank you Dinithi De Silva Associate Software Engineer Mob: +94 716 667 655
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev