remotestorage / remotestorage.js

⬡ JavaScript client library for integrating remoteStorage in apps
https://remotestoragejs.readthedocs.io
MIT License
2.3k stars 141 forks source link

Error "Cannot read properties of null" when trying to login in the widget #1285

Open erezsh opened 1 year ago

erezsh commented 1 year ago

When running in a chrome browser extension, in the options page, I can get the widget to load and run, but when trying to connect, I get this error: TypeError: Cannot read properties of null (reading '0') at R.authorize

I would debug it further but I'm not sure where to start.

This is the code I'm using to load the widget:

const remoteStorage = new RemoteStorage({logging: true});
remoteStorage.access.claim('bookmarks', 'rw');
remoteStorage.caching.enable('/bookmarks/')

import Widget from 'remotestorage-widget'
const widget = new Widget(remoteStorage);
widget.attach();

And this is how it looks: (stuck loading + error)

image

erezsh commented 1 year ago

Update: In Firefox I'm getting the same behavior, but a different error: TypeError: b.redirectUri.match(...) is null

raucao commented 1 year ago

The widget is currently not prepared for use in browser extensions. See #1205 for a detailed explanation.

I would recommend to forgo the widget, and implement the RS connect UI yourself. Have a look at the widget source code to see how this can be done. It's actually quite simple. (The widget only uses public APIs of remoteStorage.js.)

Feel free to ask any questions on the way, if you try this route. Maybe we can turn it into a documentation page for this topic.