import { fetch } from 'wix-fetch'; const CLIENT_ID = "25002D2C8D414ABE91244AFF1A5878BE"; const CLIENT_SECRET = "cj_SD_I87Hok_uzmDoDxqvH3uB3nsETw4ZSIGq-hQq0"; const REDIRECT_URI = "https://www.striven.com.au/contact-us-xero"; const AUTHORIZATION_URL = "https://login.xero.com/identity/connect/authorize"; const TOKEN_URL = "https://identity.xero.com/connect/token"; const SCOPE = "openid profile email accounting.transactions"; export function getXeroAuthUrl() { return `${AUTHORIZATION_URL}?response_type=code&client_id=${CLIENT_ID}&redirect_uri=${encodeURIComponent(REDIRECT_URI)}&scope=${encodeURIComponent(SCOPE)}`; } export async function getXeroToken(authCode) { const response = await fetch(TOKEN_URL, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded", }, body: `grant_type=authorization_code&code=${authCode}&redirect_uri=${encodeURIComponent(REDIRECT_URI)}&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}`, }); return response.json(); } import { getXeroAuthUrl, getXeroToken } from 'backend/xeroAuth'; export function startXeroLogin() { getXeroAuthUrl().then(url => { window.location.href = url; }); } export function handleXeroCallback() { const params = new URLSearchParams(window.location.search); const authCode = params.get("code"); if (authCode) { getXeroToken(authCode).then(tokenResponse => { console.log("Xero Token:", tokenResponse); // Save token and use for API calls }).catch(err => console.error("Error fetching token:", err)); } }
top of page

Let's Chat

Phone

Email

Social Media

03 9696 7300

  • Facebook
  • LinkedIn
  • Youtube

Thanks for submitting!

bottom of page