问题
I am working on a Xero integration and am having some issues setting up the XeroClient from the SDK. We are currently working in a React app written with Typescript.
Currently I am importing Xero SDK like this:
import { XeroClient } from 'xero-node';
And defining the client like this:
const xero = new XeroClient({
clientId: client_id,
clientSecret: client_secret,
redirectUris: [redirectUri],
scopes: scopes.split(' '),
});
Xero-node version: 4.0.6
React version: 16.12.0
But when compiling the app I get the following errors. Do you have any ideas as to what might be happening? Console Logs Browser Error
Might be related to this existing question.
回答1:
Currently the xero-node project requires a backend to authenticate.. Is this a react SPA, or you are just setting up the API calls in the component?
Will OAuth 2.0 support desktop/mobile/single-page apps that can’t keep a client secret confidential?
At the moment, we require that your app can keep a client secret confidential. We are currently evaluating the PKCE extension to better support SPAs and mobile apps.
https://developer.xero.com/faq/oauth2/oauth-non-secret
Your Console error looks like its just the Unused vars expression.. Here is some context on what that is ( https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md )
Your Secondary browser error makes me think that you are using an older version of Node.. We need to add an .npmrc
that forces a supported node version - are you using an older Node VSN?
来源:https://stackoverflow.com/questions/59560642/integration-xero-in-reactjs-application-causes-errors