User credentials authentication + MFA solved #194
LuisFalcon003
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been using sp-rest-proxy for the last 8 years through user credentials authentication strategy (username and password), then MFA came in for security reasons and I couldn't run the proxy in my local enviroment anymore. I tried setting up PnP library authentication directly in my projects and get away from sp-rest-proxy, but it requires changes far from configuration. After trial and error, I ended up with the following steps in order to keep using sp-rest-proxy with username and password + MFA in my Angular and React projects:
SOME GOTCHAS:
Unable to find Electron app at D:\2.Projects\ABC
Cannot find module 'D:\2.Projects\ABC'
Require stack:
SOLUTION: The project's full path folder name has spaces (in this case: "ABC SGD"). Avoid spaces in your folder name. Make sure all your parent folders from the root folder have no spaces.
Or a json error in the proxy sever (e.g.: http://localhost:8080/ ):
{
"readyState": 4,
"responseText": "Proxy Error: Cannot read properties of undefined (reading 'toString') (see more in sp-rest-proxy console)",
"status": 400,
"statusText": "Bad Request"
}
SOLUTION: This indicates a failure in the interactive authentication process using the OnDemandCredentials strategy.
The OnDemandCredentials strategy requires a tool like Electron or a web browser instance to pop up, allowing you to manually enter your SharePoint credentials. Since the proxy is crashing with a JavaScript error, it means this interactive sign-in mechanism is failing before it can complete. Re-install sp-rest-proxy, node-sp-auth and node-sp-auth-config or even better run all steps above.
SOLUTION: This error occurs when a sticky session persist from a previous login, most likely because you selected the option to persist the session. Execute %appdata% or C:\Users<your-user>\AppData\Roaming, then delete Electron folder.
Happy coding!
All reactions