Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
ananyasingh
Contributor
Contributor

Fetch data using Xero API (Oauth2.0) in TOS - DI v7.3

Hi,

I want to get data from Xero API which uses OAuth2.0 authentication. Any idea how can I achieve this in TOS-DI v7.3?

 

Addition info:

As mentioned in the document, I need to first generate a code(refresh token) using which I will get my Bearer Token.

Xero link:

https://developer.xero.com/documentation/guides/oauth2/auth-flow/#3-exchange-the-code

 

Thanks in advance.

Labels (3)
9 Replies
gjeremy1617088143

Hi, you can use TrestClient component with Oauth2.0 as authentification parameter.

Send me Love and Kudos

ananyasingh
Contributor
Contributor
Author

Umm yeah, but how to get the Bearer Token?

Okay, I think I need to edit my post to explain it in more detail.

Thanks anyways 🙂

gjeremy1617088143

everithing is explained in your doc :

you have to make a first call with a post method

https://identity.xero.com/connect/token

 

with some info in the body

and a specific header for the authorization

 

 

gjeremy1617088143

you have to write a String named string wich contain the grant type (authorization_code), code and redirect_uri

  • grant_type=authorization_code
  • code=The authorization code you received in the callback
  • redirect_uri=The same redirect URI that was used when requesting the code

with this value:

"grant_type=authorization_code&code=xxxxxx&redirect_uri=https://myapp.com/redirect"

 

you could do this in a trowgenerator or a tfixedflowinput for example.

Then connect it to the trestclient with a main row.

In trestclient :

URL : "https://identity.xero.com/connect/token"

HTTP Method : POST , Content Type FORM , Accept Type Any

in advanced setting :

Http Headers

name : "authorization" value : "Basic " + Base64.encode((client_id + ":" + client_secret).getBytes())

ananyasingh
Contributor
Contributor
Author

okay, but that's step-3 but how to implement step-1 and 2?

gjeremy1617088143

It's seems you can do part 1 and 2 with an app not talend cause you have redirection and not json response.

ananyasingh
Contributor
Contributor
Author

yeah, I also kind of resonate with you on this. Although I am hoping to get an official response from Talend.

I tried doing it in thttprequest and trestclient but none of them worked.

In trestclient, there is an option to check the "Follow redirects" and "Allow non-same host redirects" which I did and I gave my Xero creds in "Basic HTTP" authentication but no luck. It's returning an HTML.

 

Is there any other Talend product that can handle this?

gjeremy1617088143

maybe you have the info in the html , you can extact them if you can see specific pattern inside.

ananyasingh
Contributor
Contributor
Author

nope. it was just a nonfunctional HTML doc with tags like username and password. My trestclient is just reading the content of the redirect URL and not passing the username password which I have provided in the component.