bunqCommunity / bunqJSClient

A javascript SDK for the bunq API
MIT License
58 stars 23 forks source link

RegisterDevice fails with status code 200 (We couldnt verify received response) #61

Open AppElent opened 4 years ago

AppElent commented 4 years ago

Hi,

getting a bad request error even when status code is 200. Trying to do this:

        // load and refresh bunq client
        this.environment = environment;
        console.log('Connecting to environment ' + environment);
        console.log(this.bunqJSClient);
        console.log('key: ' + encryptionKey);
        console.log('accesstoken: ' + accessToken);

        await this.bunqJSClient.run(accessToken, ['*'], environment, encryptionKey).catch(this.defaultErrorLogger);

        // disable keep-alive since the server will stay online without the need for a constant active session
        this.bunqJSClient.setKeepAlive(false);

        console.log('create/re-use a system installation');
        await this.bunqJSClient.install().catch(this.defaultErrorLogger);

        console.log('create/re-use a device installation');
        try {
            await this.bunqJSClient.registerDevice('AdministratieApp');
        } catch (err) {
            console.log('Fout bij laden van BunqClient', err.response.data, err);
            return;
        }

this console logs correct values: key: eb25a36bf06693e0a280b3848aa87a2d accesstoken: sandbox_3187d660a5d98bb8d84aabaf726df55ddb3e4dbac89998b6fc220755

This is the whole response: key: eb25a36bf06693e0a280b3848aa87a2d accesstoken: sandbox_3187d660a5d98bb8d84aabaf726df55ddb3e4dbac89998b6fc220755 bunqJSClient run === Loading session data === BUNQJSCLIENT_SANDBOX_SESSION_ec443951d0af67a780d8a95ef57cd8df No stored session found create/re-use a system installation === Testing installation === Installation valid: false this.serverPublicKey = null this.installToken = null POST: /v1/installation create/re-use a device installation === Testing device installation === Device valid: false this.deviceId: null POST: /v1/device-server Fout bij laden van BunqClient {"Response":[{"Id":{"id":82546}}]} CustomError: We couldn't verify the received response at ApiAdapter.request (D:\Dev\administratie-app\node_modules\@bunq-community\bunq-js-client\dist\ApiAdapter.js:156:23) at processTicksAndRejections (internal/process/task_queues.js:93:5) at ApiAdapter.post (D:\Dev\administratie-app\node_modules\@bunq-community\bunq-js-client\dist\ApiAdapter.js:90:26) at DeviceRegistration.add (D:\Dev\administratie-app\node_modules\@bunq-community\bunq-js-client\dist\Api\DeviceRegistration.js:25:26) at BunqJSClient.registerDevice (D:\Dev\administratie-app\node_modules\@bunq-community\bunq-js-client\dist\BunqJSClient.js:138:34) { response: { status: 200, statusText: 'OK', headers: { date: 'Wed, 01 Apr 2020 18:33:08 GMT', 'content-type': 'application/json', 'transfer-encoding': 'chunked', connection: 'close', server: 'Apache/2.4.18 (Ubuntu)', 'access-control-allow-origin': '', 'x-bunq-client-request-id': '1585765989213.5388', 'x-bunq-client-response-id': '055a9f78-335b-475c-8c68-02fd6583b780', 'x-bunq-server-signature': 'PAQx5/XMqw4ylFln6T5/28OCE+1RthsCOgUMPV0PHgNnd7Bv1aepM89IJDPjBcJW5NgTusz1YyM7Lq/AaHQ7j2seLaue9HCk6Lfm9L8CI+GazioVjEoaJ5E2UsdysAtQTNOBm+j5/5TmgeGeBrPpTvyC4mgdfIi2yWuzMFjGQS/Ner0LpdxWyngxqPBYTa+sEsaxEU/32hH+4WDNidz+cE4fzDsH2WaqupAeSas5iW9Qoea3xWoMwFFnm3LCk42TFIGnX1fxTCBkoBAybQu5pmsvhzrWvCbh5ftstMYj3SWGmDWce971jmHYBoRxxoWx4ot665goBCHVZr23lw7uOw==', 'x-frame-options': 'sameorigin' }, config: { adapter: [Function: httpAdapter], transformRequest: [Object], transformResponse: undefined, timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], headers: [Object], method: 'post', url: 'https://public-api.sandbox.bunq.com/v1/device-server', data: '{"description":"AdministratieApp","secret":"sandbox_3187d660a5d98bb8d84aabaf726df55ddb3e4dbac89998b6fc220755","permitted_ips":[""]}' }, request: ClientRequest { _events: [Object: null prototype], _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, _last: true, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [TLSSocket], connection: [TLSSocket], _header: 'POST /v1/device-server HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /\r\n' + 'Content-Type: application/json\r\n' + 'Cache-Control: no-cache\r\n' + 'X-Bunq-Geolocation: 0 0 0 0 000\r\n' + 'X-Bunq-Language: en_US\r\n' + 'X-Bunq-Region: nl_NL\r\n' + 'X-Bunq-Client-Request-Id: 1585765989213.5388\r\n' + 'X-Bunq-Client-Authentication: 21fb9c1986b25d5799dee943ec0c778a56878ad97347c52c781a5d51b189ab70\r\n' + 'User-Agent: Node-v12.14.0-bunqJSClient\r\n' + 'X-Bunq-Client-Signature: UEmkW2JY0Qu6IlfNuPqFoQYjReHB/DBgf4JnrkMW5nHExW6UEgYXC846+lSLu95GkPaTITWZ24L4fdiNWAXMjhS0WD2WVArify1rqvO6qXSl1XOwegPskYuMVb66PNZFoPqZJno7+hGZebNtl8upcigrT6x5vuShVMkbbyhLiTlVAg86GteF0hFss7BV/ak1AVSFrAXceCI4ZVYgikkxxov53W7xB1h2QCFNoPghKrNdGk9DEAUUve3gAmrbgxQZfeZQhtSYO2//jc2+MZ1W+S6/fkSM3WWiXfTnlYoc0d2L7zzx8Oi0H5TrjqVmpUXKnmhkVsKswpHJUMTvK82/pw==\r\n' + 'Content-Length: 132\r\n' + 'Host: public-api.sandbox.bunq.com\r\n' + 'Connection: close\r\n' + '\r\n', _onPendingData: [Function: noopPendingOutput], agent: [Agent], socketPath: undefined, method: 'POST', path: '/v1/device-server', _ended: true, res: [IncomingMessage], aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, _redirectable: [Writable],

  [Symbol(isCorked)]: false,
  [Symbol(kOutHeaders)]: [Object: null prototype]
},
data: '{"Response":[{"Id":{"id":82546}}]}'

}, errorCode: 'INVALID_RESPONSE_RECEIVED', name: 'CustomError' }

strunkie30 commented 4 years ago

Update package and remove storage.json. Also generating a new EAS key will help to solve this issue.