[resolved] OAuth 1.0a with tRESTClient / tRESTResponse / tRESTRequest

Highlighted
One Star

[resolved] OAuth 1.0a with tRESTClient / tRESTResponse / tRESTRequest

Hi Folks,
I have a need to integrate with a REST API. I tried using a tJavaFlex component and dumped some java in like:
OAuthConsumer consumer = new OAuthConsumer(null, context.consumerKey, null, null);
consumer.setProperty(RSA_SHA1.PRIVATE_KEY, context.privateKey);
consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.RSA_SHA1);
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.accessToken = context.consumerKey;
accessor.tokenSecret = context.consumerSecret;
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, OAuthMessage.GET, context.endpointUrl + "contacts", null);
... but that just gives me an input stream, It feels wrong to go calling JAXB to convert it into an XML document and map it to a bean.
Surely there's a better way ?


Accepted Solutions
Employee

Re: [resolved] OAuth 1.0a with tRESTClient / tRESTResponse / tRESTRequest

The CXF code has been updated on the trunk and branches so you might want to give it a go in few days. Alternatively, if you fine with using WebClient then
you can use a typed API if preferred, something like WebClient.get(DOM4JDocument.class) would give you an instance of DOM4J response, etc

All Replies
Employee

Re: [resolved] OAuth 1.0a with tRESTClient / tRESTResponse / tRESTRequest

Hi
I'd consider using CXF WebClient in this case, pity the existing OAuth1.0a client utility we ship does not offer a support for the RSA signatures, I'll update the code:
https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=rt/rs/security/oauth-parent/oauth/src/mai...
Have a look at the code, you can just create a header, then do
WebClient wc = WebClient.create("someaddress");
wc.header("Authorization", oauth1Header);
wc.get();
//etc
as I said, I'll update the utility code in meantime to make it simpler
HTH, Sergey
Employee

Re: [resolved] OAuth 1.0a with tRESTClient / tRESTResponse / tRESTRequest

The CXF code has been updated on the trunk and branches so you might want to give it a go in few days. Alternatively, if you fine with using WebClient then
you can use a typed API if preferred, something like WebClient.get(DOM4JDocument.class) would give you an instance of DOM4J response, etc

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read