koltyakov / sp-rest-proxy

🌐 SharePoint API Proxy for local development
MIT License
172 stars 43 forks source link

Error 400 - Cannot read property 'length' of undefined #77

Closed BlueBird67 closed 5 years ago

BlueBird67 commented 5 years ago

Hello, I use your proxy a lot for my SPFX dev on SP Online, thanks for that!

On a new SPO tenant, I have a strange problem, error is : { "readyState": 4, "responseText": "Cannot read property 'length' of undefined", "status": 400, "statusText": "Bad Request" }

But the request is good, it is working directly on the tenant (https url GET), and not with the proxy. The same proxy configured with my DEV tenant information is working. Just not on the PROD client tenant...

Version used is 2.8.9

Any idea? Thanks.

Some precision : it is an O365 tenant : xxxxx.sharepoint.com, but I have only access on some collection sites like xxxxx.sharepoint.com/sites/specificsite , and not on the root collection. Could this be the problem?

koltyakov commented 5 years ago

Hi @BlueBird67,

Thanks for using the library! Is it a specific request which doesn't work? Or any request via proxy to the tenant? Does the authentication work? Could you check if auth works e.g. using this helper project?

BlueBird67 commented 5 years ago

Thanks for answer. Just to be sure, for tenant URL I put xxxx.sharepoint.com, and not xxxx.sharepoint.com/sites/sitecolyyyy ?

I use SAML authentication, and I just tried with sitecolyyyy as the sharepoint config url, the error is exactly the same.

Here are the error from the test :

=== Error === TypeError: Cannot read property 'length' of undefined at getSecurityToken.then.then.data (D:\Dev\node-sp-auth-troubleshoot\node_modules\node-sp-auth\lib\src\auth\resolvers\OnlineUserCredentials.js:55:64) at tryCatcher (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\promise.js:512:31) at Promise._settlePromise (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\promise.js:569:18) at Promise._settlePromise0 (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\promise.js:694:18) at _drainQueueStep (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\async.js:147:5) at Immediate.Async.drainQueues (D:\Dev\node-sp-auth-troubleshoot\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:810:20) at tryOnImmediate (timers.js:768:5) at processImmediate [as _immediateCallback] (timers.js:745:5)

koltyakov commented 5 years ago

So it’s definitely an authentication thing. Could it be that ADFS with custom provider is used or you’re using external user account? The option to try is AddIn Only permissions auth.

BlueBird67 commented 5 years ago

Effectively, I forget to say that it is with an external user, shame on me. It mean it cannot work?

koltyakov commented 5 years ago

I'm afraid, nope. External users can't be used in SAML auth. Not completely sure if this only an auth library (node-sp-auth) related or SPO limitation/nuance.

BlueBird67 commented 5 years ago

Ok, I can understand that. Anyway, I'm using the distant Workbench and it's working this way for now.

You can close my issue, which is certainly a Sharepoint limitation. Thanks.

koltyakov commented 5 years ago

Thanks for understanding!