Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get name of the connections in OAuth2?

Tags:

xero-api

After successfully establishing OAuth2 connection to Xero, call to https://api.xero.com/connections is giving only the id, tenant id and type.

How to get the name (display name) of the connections?

Tried calling Organizations API. It does not work in OAuth2

var url = "https://api.xero.com/connections";

  //var response = service.fetch(url, {
  var response = UrlFetchApp.fetch(url, {
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer ' + service.getAccessToken(),
    },
    muteHttpExceptions : true
  });

There is no way of getting connection names and showing it to end-user to choose. (It makes no sense to ask the user to choose from the list of cryptic ids).

like image 997
Michaes Avatar asked Nov 25 '25 04:11

Michaes


1 Answers

You should retrieve each organisation from the /organisation endpoint, with the appropriate tenantId as the value in the xero-tenant-id header:

https://api.xero.com/api.xro/2.0/organisation

This works with both OAuth1.0a and OAuth2 (note the 's' rather than the 'z' in the endpoint).

like image 67
rustyskates Avatar answered Nov 28 '25 15:11

rustyskates



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!