I'm writing a new winforms c# integration into Xero. oauth1 is deprecated, Xero.netstandard.oauth2 is the correct SDK to use but some things are flagged as 'coming soon', including UK payroll. My oauth2 authentication is completed, and the accountingapi is drama free.. But my customer requires payroll integration, how can i accomplish this in the meantime? Do i have to use the soon-to-be-deprecated xero.api.sdk? Seems crap to say the least if that is the case..
Asked
Active
Viewed 79 times
0
-
1You will get a better answer if you contact the support staff at Xero. – Gusman Jun 16 '20 at 22:44
2 Answers
1
great to see you are working on the OAuth 2.0 code base and is ahead of many devs. We are working hard on improving the SDKs projects to streamline the process and will introduce Payroll UK API soon! Soon is a relative term, I am afraid when I say this, it is still at least 2 weeks away from today.
But don't let that stop you from rolling your own API client that interface with our APIs directly with JSON objects! The API is well specified in our OpenAPI spec, you can even generate your own SDK with the help of any OpenAPI generators out there.

Jenks Guo
- 36
- 2
-
Yes, this is well worth looking at. I'm just finishing off a transfer from OA1 to OA2 in vb, and have only used the API to get the structures, I don't use any API calls to actually talk to Xero, just plain old HTTP to the various endpoints, mainly as I was struggling to get my head around all the async calls in the API. – droopsnoot Jun 17 '20 at 09:05
-
@droopsnoot thanks for the reply, i've taken the yaml from the OpenAPI docs and generated a C# client using Nswag but i'm struggling with the implementation.. do you have an example of how you've made it work please? – Lee Stevens Jun 17 '20 at 14:35
-
It's a bit difficult for me to post my code as I'm writing it for someone else, so it's not really mine. I just build the various objects using the appropriate mode, JSON-encode it and then call a routine to HTTP PUT or POST the json object to the correct endpoint, with the appropriate headers. There's a video on the Xero youtube channel that covers migrating a private app that shows the http interaction quite nicely. – droopsnoot Jun 17 '20 at 17:33
-
@Jenks Guo, i've taken the yaml from the OpenAPI link and generated a C# client using Nswag. I'm getting a 401 Authentication Error, i'm adding my oAuth token to the http client...(MyHttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);... Is this the correct approach? Thanks – Lee Stevens Jun 18 '20 at 07:38
-
@LeeStevens hey sorry about the late reply, the generation does not look after oauth 2.0 flow. You can use the Xero.NetStandard.Oauth2.Client to interface with OAuth 2.0 and get the access token and tenant ID for firing an API. – Jenks Guo Jun 23 '20 at 03:24
-
@LeeStevens read more about the OAuth 2.0 flow here: https://developer.xero.com/documentation/oauth2/overview If you watch this video, it talks about the process of getting access token back: https://www.youtube.com/watch?v=UO-TIHhWjX4&t=280s – Jenks Guo Jun 23 '20 at 03:24
0
All sorted now. Turned out to be a Scope error, the token already being generated by the .netstandard.oauth2 client was correct in all other respects. UKPayroll now working off our own sdk. Thanks

Lee Stevens
- 43
- 1
- 4