23 lines
501 B
TypeScript
23 lines
501 B
TypeScript
import { XeroClient } from "xero-node";
|
|
|
|
/**
|
|
* Creates a XeroClient using an already-valid access token.
|
|
*
|
|
* IMPORTANT:
|
|
* - Token refresh is handled elsewhere (auth.ts)
|
|
* - This client MUST NOT call refreshToken()
|
|
*/
|
|
export function getXeroClient(accessToken: string): XeroClient {
|
|
if (!accessToken) {
|
|
throw new Error("Xero access token missing");
|
|
}
|
|
|
|
const xero = new XeroClient();
|
|
|
|
xero.setTokenSet({
|
|
access_token: accessToken,
|
|
token_type: "Bearer",
|
|
});
|
|
|
|
return xero;
|
|
}
|