Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

xoauth set custom callback URI

Started by Sylvain Gantois -   in API Authentication


I have been trying to setup an M2M connection using client id / secret.

If I understand correctly, a user needs to authorize the connection once in the browser so that we can retrieve access/refresh tokens using the code sent to the callback URI. From then, a program can use the refresh token to generate new tokens every time it runs as long as it is within the 60days of the refresh token validity period.

So I setup a web application for the callback URI to retrieve code and state.

My plan was then to use xoauth and log once with a user to retrieve the code and then request tokens and store them.
Unfortunately, I cannot figure out how to setup my custom callback URI with xoauth.
xoauth says
"Remember, make sure you've added http://localhost:8080/callback as a redirect_uri in your identity provider's portal".

Is there a way to set my own redirect_uri in xoauth (the one I set for my web app)?
Or am I not understanding the process correctly / what should I do to have a program periodically pulling data from my Xero account without using custom connection?

Thank you
I was able to retrieve the code/state by not using xoauth.
Instead, in my app I have the following code which is triggered when I don't have generated a Xero token yet:

XeroConfiguration XeroConfig = new XeroConfiguration
ClientId = xeroConfig.ConsumerKey,
ClientSecret = xeroConfig.ConsumerSecret,
CallbackUri = new Uri("<my callback url>"),
Scope = "openid offline_access accounting.transactions accounting.contacts"

var client = new XeroClient(XeroConfig);
var redirect_url = client.BuildLoginUri();
Process.Start(new ProcessStartInfo(redirect_url) { UseShellExecute = true });

The callback receives code/state and generates the token to be stored.

Sylvain Gantois