Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection gets immediately revoked after authorisation #1182

Open
ProggerPete opened this issue May 27, 2020 · 5 comments
Open

Connection gets immediately revoked after authorisation #1182

ProggerPete opened this issue May 27, 2020 · 5 comments

Comments

@ProggerPete
Copy link

I'm using the remotestorage-widget. Auth appears to work but then I get an expired or revoked message.

These are the logs:

[RemoteStorage] [FEATURE IndexedDB] supported
log.js:12 [RemoteStorage] [FEATURE IndexedDB] initialized.
log.js:12 [REMOTESTORAGE] All features loaded !
log.js:12 [Eventhandling] Adding event listener change
log.js:12 [Eventhandling] Adding event listener connected
log.js:12 [Eventhandling] Adding event listener not-connected
log.js:12 [Sync] syncCycleCb calling syncCycle
log.js:12 [Eventhandling] Adding event listener background
log.js:12 [Eventhandling] Adding event listener foreground
log.js:12 [Caching] Setting activate handler ƒ (e) {
r.addTask(e), r.doTasks();
} ["/"]
log.js:12 [Sync] syncCycleCb calling syncCycle
log.js:12 [Eventhandling] Adding event listener sync-done
log.js:12 [Eventhandling] Adding event listener sync-req-done
log.js:12 [Eventhandling] Adding event listener sync-done
VM56:1 GET https://storage.5apps.com/proggerpete/ 401
(anonymous) @ VM56:1
w._fetchRequest @ wireclient.js:478
w.request @ wireclient.js:460
_request @ wireclient.js:205
get @ wireclient.js:376
(anonymous) @ sync.js:342
Promise.then (async)
value @ sync.js:339
value @ sync.js:948
(anonymous) @ sync.js:97
onActivate @ caching.js:86
e @ sync.js:93
f @ sync.js:1011
(anonymous) @ eventhandling.js:40
_emit @ eventhandling.js:39
_fireReady @ features.js:178
(anonymous) @ features.js:206
(anonymous) @ eventhandling.js:40
_emit @ eventhandling.js:39
configure @ wireclient.js:312
a @ authorize.js:192
(anonymous) @ eventhandling.js:40
_emit @ eventhandling.js:39
featuresLoaded @ features.js:226
setTimeout (async)
featureDone @ features.js:158
featureInitialized @ features.js:148
(anonymous) @ features.js:125
Promise.then (async)
initFeature @ features.js:123
(anonymous) @ features.js:98
Promise.then (async)
loadFeature @ features.js:94
loadFeatures @ features.js:46
b @ remotestorage.js:133
./src/App.js @ App.js:18
webpack_require @ bootstrap:784
fn @ bootstrap:150
./src/index.js @ index.css?f3f6:45
webpack_require @ bootstrap:784
fn @ bootstrap:150
1 @ serviceWorker.js:141
webpack_require @ bootstrap:784
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.chunk.js:1
log.js:12 [WireClient fetch] Response {type: "cors", url: "https://storage.5apps.com/proggerpete/", redirected: false, status: 401, ok: false, …}
log.js:12 [WireClient] Error response status 401
log.js:12 [Sync] Error u.Unauthorized {name: "Unauthorized", message: "App authorization expired or revoked.", stack: "Error↵ at new u.Unauthorized (http://localhost:…tp://localhost:3000/static/js/0.chunk.js:94267:22"}
log.js:12 [Sync] Sync done. Setting timer to 10000

@raucao
Copy link
Member

raucao commented May 27, 2020

Could you add a little bit more context, and ideally link example source code, where this happens? Thanks.

@ProggerPete
Copy link
Author

ProggerPete commented May 27, 2020

I'm not at the point of trying to do anything with it yet, Just following the getting started guide and got to here (https://remotestoragejs.readthedocs.io/en/latest/getting-started/connect-widget.html) and saw errors instead of the instant gratification I was hoping for. =)

My code looks like:

import Widget from 'remotestorage-widget';
import RemoteStorage from 'remotestoragejs';

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

const widget = new Widget(remoteStorage);
widget.attach();

This is running in a create-react-app running on http://localhost:3000

@galfert
Copy link
Member

galfert commented May 27, 2020

Hi. I think it's because of the line

remoteStorage.caching.enable('/')

That will trigger sync requests to the root directory, which the app doesn't have access for, because it only claimed access to the tester category.

Try remoteStorage.caching.enable('/tester/') instead, that should work.

@galfert
Copy link
Member

galfert commented May 27, 2020

Maybe the library should give a proper error message when trying to enable caching for a category that hasn't been claimed access for. That way it wouldn't even make the network requests that result in a 401 response in the first place.

@ProggerPete
Copy link
Author

Thanks @galfert !

You were correct, it's working now. A better error would definitely be useful.

Also when I read the documentation (https://remotestoragejs.readthedocs.io/en/latest/getting-started/initialize-and-configure.html#configuring-caching) when it talked about paths I assumed it was talking about the path in the url for the page, similar to how cookies can be set for sub-paths. I'm sure the difference is obvious for people familiar with remote storage, but others like me who are looking at it for the first time may be similarly confused.

Really interesting project though, I'm keen to see what I can do with it!

Regards,
Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants