koltyakov/sp-rest-proxy

Cannot read properties of null (reading 'toString')

smailsw opened this issue · 3 comments

Hello i have this issue with OnDemande Auth,

node-sp-auth-troubleshoot

`npm run test -- --env uat

node-sp-auth-troubleshoot@2.0.0 test
node ./index.js "--env" "uat"

Connecting to site: https://x.sharepoint.com/sites/y

=== Error ===
TypeError: Cannot read properties of null (reading 'toString')
at OnDemand.saveAuthData (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:83:44)
at OnDemand.getAuth (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:38:28)
at getAuth (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node_modules\node-sp-auth\lib\src\index.js:16:76)
at C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node-sp-auth-troubleshoot\index.js:22:30
at processTicksAndRejections (node:internal/process/task_queues:96:5)`

sp-rest-proxy

`npm run serve

sp-rest-proxy@3.3.5 serve
ts-node ./src/server

SharePoint REST Proxy has been started on http://localhost:8080

GET (generic): https://x.sharepoint.com/sites/y/api
Error TypeError: Cannot read properties of null (reading 'toString')
at OnDemand.saveAuthData (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:83:44)
at OnDemand.getAuth (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:38:28)
at Object.getAuth (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\node_modules\node-sp-auth\lib\src\index.js:16:76)
at SPClient. (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\src\utils\client.ts:47:32)
at step (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\src\utils\client.ts:44:23)
at Object.next (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\src\utils\client.ts:25:53)
at C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\src\utils\client.ts:19:71
at new Promise ()
at __awaiter (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\src\utils\client.ts:15:12)
at SPClient.fetch (C:\Users\Ismail\Desktop\JTR Redesign\sp-rest-proxy\src\utils\client.ts:65:20)`

- Electron Version : 8.5.5

Screenshot 2022-09-05 163405

Hi there!

For OnDemand auth. Electron must be installed locally or globally.

Run npm i -D electron for this strategy to work.

@koltyakov
I have been facing this same issue. I have installed the dev dependency of Electron as you stated above, and have sp-rest-proxy V 3.3.5. I created a fresh Node Project as a test with only sp-rest-proxy and am getting the error below. When I trace the error, i get an EONENT error on childprocess.spawnsync.
GET: https://www.sharepoint.com/sites/mysite/ Error TypeError: Cannot read properties of null (reading 'toString') at OnDemand.saveAuthData (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:83:44) at OnDemand.getAuth (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:38:28) at Object.getAuth (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\index.js:16:76) at SPClient.<anonymous> (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:69:51) at step (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:44:23) at Object.next (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:25:53) at c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:19:71 at new Promise (<anonymous>) at __awaiter (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:15:12) at SPClient.fetch (C:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:65:20) {stack: 'TypeError: Cannot read properties of null (re…les\sp-rest-proxy\dist\utils\client.js:65:20)', message: 'Cannot read properties of null (reading 'toString')'} arg1: TypeError: Cannot read properties of null (reading 'toString')\n at OnDemand.saveAuthData (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\OnDemand\\OnDemand.js:83:44)\n at OnDemand.getAuth (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\OnDemand\\OnDemand.js:38:28)\n at Object.getAuth (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\index.js:16:76)\n at SPClient.<anonymous> (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:69:51)\n at step (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:44:23)\n at Object.next (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:25:53)\n at C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:19… … Logger.error @ c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\logger.js:51:25 <anonymous> @ c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\core\BasicRouter.js:118:34 processTicksAndRejections @ internal/process/task_queues:96:5

pakcage.json as follows
{ "name": "spo-proxy", "version": "1.0.0", "description": "Proxy to SharePoint online", "main": "index.js", "scripts": { "proxy": "node ./index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "sp-rest-proxy": "^3.3.5" }, "devDependencies": { "electron": "^20.1.3" } }

i was able to fix the problem by using WSL2 installed it on my win10 system, then pull sp-rest-proxy in a new folder there, installed gpu drivers for linux and xserver in windows, then run the project, and it started and called electron instance without any problems.