Skip to content

Instantly share code, notes, and snippets.

@SerKnight
Created January 8, 2021 18:00
Show Gist options
  • Save SerKnight/b9bc098f77b69b4062b26120324537fd to your computer and use it in GitHub Desktop.
Save SerKnight/b9bc098f77b69b4062b26120324537fd to your computer and use it in GitHub Desktop.
XeroConfiguration xconfig = new XeroConfiguration();
xconfig.ClientId = "yourClientId";
xconfig.ClientSecret = "yourClientSecret";
xconfig.CallbackUri = new Uri("https://localhost:5001") //default for standard webapi template
xconfig.Scope = "openid profile email files accounting.transactions accounting.contacts offline_access";
var client = new XeroClient(xconfig);
//before getting the access token please check that the state matches
await client.RequestAccessTokenAsync(code);
//from here you will need to access your Xero Tenants
List<Tenant> tenants = await client.GetConnections();
// you will now have the tenant id and access token
foreach (Tenant tenant in tenants)
{
// do something with your tenant and access token
//client.AccessToken;
//tenant.TenantId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment