Я развернул приложение ExpressJs в функции firebase и пытаюсь запустить приложение express с помощью HTTP-триггера.
Я пытаюсь авторизовать мое приложение express с OAUTH2. 0 для использования QuickBooks API. Тем не менее, я получаю следующую ошибку:
TypeError: Redirected path should match configured path, but got: /callback
at CodeFlow.getToken (/srv/node_modules/client-oauth2/src/client-oauth2.js:597:7)
at /srv/routes/callback.js:12:25
at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)
at next (/srv/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/srv/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)
at /srv/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/srv/node_modules/express/lib/router/index.js:335:12)
at next (/srv/node_modules/express/lib/router/index.js:275:10)
at Function.handle (/srv/node_modules/express/lib/router/index.js:174:3)
Ошибка в следующем файле: обратный вызов. js
router.get('/', function (req, res) {
// Verify anti-forgery
console.log("OriginalURL "+req.originalUrl)
console.log("base URL "+req.baseUrl)
// Exchange auth code for access token
tools.intuitAuth.code.getToken(req.originalUrl).then(function (token) { //This is where promise is failing
Я использую пакет npm под названием "client- oauth2" . client-oauth2. js
if (
typeof options.redirectUri === 'string' &&
typeof url.pathname === 'string' &&
url.pathname !== Url.parse(options.redirectUri).pathname
) {
return Promise.reject(
new TypeError('Redirected path should match configured path, but got: ' + url.pathname) //The source of Error. I am not able to find out the value of options.redirectUri
)
}
Ниже приведены мои данные конфигурации:
"redirectUri": "us-central1-thematic-runner-245505.cloudfunctions.net/createEstimate/callback"
Я убедился, что этот URL соответствует URL-адресу перенаправления на стороне Quickbooks. В случае localhost он работает просто отлично.
Localhost URL: http://localhost:5001/thematic-runner-245505/us-central1/createEstimate/
Значение req.originalUrl от обратного вызова. js равно
OriginalURL /thematic-runner-245505/us-central1/createEstimate/callback?code=AB11585447829JwgpXMEpWOR6irwprMe9Z8aqRoSK4npFDKmte&state=Z0t9yRkl-dWaO2J5sJRDaTB9eZKvyyyVcHYQ&realmId=4620816365002391850
Может кто-нибудь помочь мне с этой ошибкой? Я не знаю, что я делаю неправильно в случае производства. URL обратного вызова, кажется, в порядке. Любая помощь будет оценена.