You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When have multi clients, The API client's Oauth2Token keeps the same #99
I have an app that connects to many client_ids, and I found their's client_id and client_secret keep the same even though I put different config,
here are some test codes:
@RettBehrens We set up each app for each billing entity because some business logic there has different scopes and we need to separate them. And run some corn job base on them. for now I have to assign the OauthToken again to avoid this issues
@RettBehrens Test from nodejs sdk. it works as excepted. differences API clients have different config. here's the test code
const { XeroClient } = require('xero-node');
const xero1 = new XeroClient({
clientId: 'clientId1', // required
clientSecret: 'clientSecret1', // required
redirectUris: [`http://localhost/callback`], // not used for client_credentials auth flow
grantType: 'client_credentials', // only used for client_credentials auth flow
scopes: 'openid profile email accounting.transactions offline_access'.split(" "), // not used for client_credentials auth flow
state: 'returnPage=my-sweet-dashboard', // custom params (optional), not used for client_credentials auth flow
httpTimeout: 3000 // ms (optional)
});
const xero2 = new XeroClient({
clientId: 'clientId2', // required
clientSecret: 'clientSecret2', // required
redirectUris: [`http://localhost/callback`], // not used for client_credentials auth flow
grantType: 'client_credentials', // only used for client_credentials auth flow
scopes: 'openid profile email accounting.transactions offline_access'.split(" "), // not used for client_credentials auth flow
state: 'returnPage=my-sweet-dashboard', // custom params (optional), not used for client_credentials auth flow
httpTimeout: 3000 // ms (optional)
});
console.log("xero1",xero1.config)
console.log("xero2",xero2.config)
You share Xero and our Developer Platform with your fellow developers and you should write Your Application as you’d want others to write theirs. You agree not to use, nor permit any third party to use, the Developer Platform to:
Create multiple versions of Your Applications that access the Developer Platform for the same or similar usages (e.g. creating customer-specific versions of Your Applications);
Suggested resolution - use one set of ClientID and ClientSecret credentials, adjusting what scopes are requested during auth/consent
@ezioruanconfiguration.py in Xero-Python SDK is based on a fork of OpenAPITools openapi-generator python module.
Looking at the source file from openapi-generator, I can see there is no TypeWithDefault class there, so it's presumably something the original author added.
In the Xero-Node SDK, while most of the files generated, XeroClient.ts was home-rolled rather than generated, so it's possible this restriction should have been added but was missed.
I will need to investigate further and consult with the team to determine which is the correct / expected behavior.
Looks good. Thanks for your reply. I don't know how to use the generate tools. Could you take a look to see if the newly generated files are correct (without TypeWithDefault )
We are having the same issue. We are currently using two client objects, one is using a private connection auth, and the other is using code flow auth. When using both instances in the same process it fails because the client id/secret gets mixed up.
An update on this topic. I believe I've found an issue identifying the same problem with OpenAPITools openapi-generator. Following the thread, it seems TypeWithDefault was added at some time and ultimately removed - our fork of the generator must have occurred after it was added but before it was removed. Going to take some time but I'll create a ticket to refactor the configuration so it doesn't use TypeWithDefault.
Also run into this problem when providing a setup form to enter or update the API credentials -- old credentials keep getting used regardless of new ones being entered. @pernofence 's workaround seems to solve it for us, thank you!
Activity
[-]The API cli[/-][+]When have multi clients, The API client's Oauth2Token keeps the same[/+]RettBehrens commentedon Sep 23, 2022
Hmmm. Could you detail your use case? What's the reasoning for swapping between ClientID and ClientSecret credentials?
ezioruan commentedon Sep 26, 2022
@RettBehrens We set up each app for each billing entity because some business logic there has different scopes and we need to separate them. And run some corn job base on them. for now I have to assign the OauthToken again to avoid this issues
I am not sure if other languages' SDK also have this behavior.
ezioruan commentedon Sep 26, 2022
@RettBehrens Test from nodejs sdk. it works as excepted. differences API clients have different config. here's the test code
output:
RettBehrens commentedon Sep 26, 2022
Hi @ezioruan what you're describing is against Xero Developer Platform Ts&Cs. Specifically section 7b Be a Good Citizen to our Ecosystem:
You share Xero and our Developer Platform with your fellow developers and you should write Your Application as you’d want others to write theirs. You agree not to use, nor permit any third party to use, the Developer Platform to:
Suggested resolution - use one set of ClientID and ClientSecret credentials, adjusting what scopes are requested during auth/consent
ezioruan commentedon Sep 27, 2022
@RettBehrens Thanks for your reply, so it's the right behavior. but why node js client can have a differences client_id for each api_client?
RettBehrens commentedon Sep 28, 2022
@ezioruan
configuration.pyin Xero-Python SDK is based on a fork of OpenAPITools openapi-generator python module.Looking at the source file from openapi-generator, I can see there is no
TypeWithDefaultclass there, so it's presumably something the original author added.In the Xero-Node SDK, while most of the files generated,
XeroClient.tswas home-rolled rather than generated, so it's possible this restriction should have been added but was missed.I will need to investigate further and consult with the team to determine which is the correct / expected behavior.
ezioruan commentedon Sep 29, 2022
Looks good. Thanks for your reply. I don't know how to use the generate tools. Could you take a look to see if the newly generated files are correct (without TypeWithDefault )
pernofence commentedon Nov 17, 2022
We are having the same issue. We are currently using two client objects, one is using a private connection auth, and the other is using code flow auth. When using both instances in the same process it fails because the client id/secret gets mixed up.
RettBehrens commentedon Nov 17, 2022
An update on this topic. I believe I've found an issue identifying the same problem with OpenAPITools openapi-generator. Following the thread, it seems TypeWithDefault was added at some time and ultimately removed - our fork of the generator must have occurred after it was added but before it was removed. Going to take some time but I'll create a ticket to refactor the configuration so it doesn't use TypeWithDefault.
ezioruan commentedon Nov 20, 2022
Looks like the bug was reported years ago but still have problems, hope we can solve this .
If there's some document about how to generate those codes I think it would be a big help
tamhv commentedon Mar 20, 2023
if we buy 2 custom connections for 2 organizations and use them in a python app, then we would end up here, the 2nd client_id can't be used
pernofence commentedon Mar 20, 2023
This workaround seems to work for me:
doctea commentedon Feb 4, 2026
Also run into this problem when providing a setup form to enter or update the API credentials -- old credentials keep getting used regardless of new ones being entered. @pernofence 's workaround seems to solve it for us, thank you!