I followed this to get our Xero resource set up and all is working well (really useful instructions thanks!), but as it's a Custom Auth, I'm missing the option to be able to 'Share credentials between users'.
Has anyone had any luck creating a connection to the Xero API for their whole application? I'd like to be able to allow our team to create invoices without having their own Xero logins.
It sounds like you're looking for a workaround similar to what I described here. Let me know if that isn't helpful or if you have any follow-up questions!
Hi @Darren. Thanks for this - that's really useful.
I've now got the data stored in a table in our DB. Sorry for what will probably be a simple answer but I've been going round in circles!... what's the best way of using this data now in a standard api call & how do I trigger it's refresh if I'm not a logged in user?
In order to utilize the stored credentials, you'll need to define a query that fetches them when your app initially loads. You can add your Xero query as a success callback to ensure it doesn't execute until you have the credentials.
Keeping your credentials current is a little tricker. One option is to add a refresh workflow to your existing custom auth solution and run it on a schedule or trigger it with a test URL
Alternatively, you can add a Auth Login component to your app that would allow your users to manually trigger the custom auth flow, resulting in refreshed credentials.
Thanks @Darren. I still can't get my head around the logic of where to pass in the values - I've tried a few different ways but not having much luck. I've also already got the refresh set up, but I presume I need to also update the refresh token with the DB in this flow? I think I'm making a simple mistake somewhere and would appreciate another pair of eyes?
For ease (and for others setting up the same sort of thing) this is my current resource set up and POST API call.
I have a table set up called XeroDetails with three columns - authToken, tenantId & refreshToken.
I think the key is that you should be defining your Authorization and Xero-tenant-id headers within the addToXero query, not inside the resource configuration. In order to do this, you'll need to first execute a query that fetches that info.
And yes, your refresh flow should update the credentials you're storing in XeroDetails.
Are you in UK, NZ or AU? I recently was able to set up a Custom Connection which does not require user authentication, and you are able to use the query in all app for the users you need (as well as in workflows). If you are in these countries, let me know and I can share the resource authentication steps!
So, I created a custom connection with both auth and refresh being identical. I'm sure there may be a more proper way of doing this (maybe @Darren can pitch in), but for now this is what is working for me.
In the Authorization, I already added my base64encode(client_id + ":" + client_secret) which I did outside this workflow.
Besides that, all the instructions are here and they are quite straightforward.
@Darren that makes so much sense and I hadn't realised I could do that outside of creating the resource in Retool so another new thing learnt!
@MiguelOrtiz your solution I think simplifies things and makes the set up feel like it's properly set up now, I hadn't spotted Custom Connections so this was really useful. In the end I managed to get your solution working correctly and it does what we need to do.