Closed lewisl9029 closed 9 years ago
Yes, without an actual origin, we have a general problem with the OAuth redirect flow being insufficient for just using it directly like that.
I think nobody else has integrated rs.js in a Cordova app so far, although there are plans for e.g. a sync app that would sync device contacts, calendars etc to and from a remote storage.
I'm not sure how other people solve this, when they only have the redirect flow to work with, but I do vaguely remember some apps using it in the past. That's definitely the place to start looking: how do people use OAuth implicit grant in native apps?
Thanks for the quick reply. That makes sense.
This is my first time using OAuth on Cordova, so I wasn't aware of the complications.
I found this article that seems to offer a solution using the inappbrowser plugin, a dummy redirect URI, and extracts the OAuth tokens from the browser URL when OAuth completes: http://phonegap-tips.com/articles/google-api-oauth-with-phonegaps-inappbrowser.html
I'll try implementing something like this for remoteStorage. In the mean time, if anyone has anything they'd like to share regarding using remoteStorage within Cordova, I'd love to hear them.
Ah, yes. That sounds like what I remembered.
So, as the user will otherwise see your app as localhost
, here's another idea for you: you could use an app-specific domain that points to localhost. E.g. @galfert set up *.lolcathost.de
to point to 127.0.0.1
for development purposes (making it easy to have different origins for different apps on localhost so that IndexedDB and localStorage aren't messed up).
So, in this case something like android.yourapp.com
could point to 127.0.0.1
and give that as redirect URI to the RS server.
@lewisl9029 Did you make any progress on this so far? I'd be super interested in a solution, because it means we could sync all kinds of data from and to phones via a single API (so we can get to e.g. all contacts or calendar entries from all the different services at once).
Let me know if I can help somehow!
I've been working on a few other features lately. I plan to start on this later this week.
I'll definitely let you know if I make any progress or run into anything I need help with. =)
Cool! Looking forward to it. Thanks for the quick update.
I managed to get it working. =) Please take a look at #880 when you have the time.
w00t!
Cordova support, contributed by @lewisl9029, just landed in master
. \o/
Using 11.2 on a Cordova Android app, I get the following exception when connecting to a @5apps.com remoteStorage account (tested to be working perfectly in Chrome):
The line responsible appears to be in authorize.js: https://github.com/remotestorage/remotestorage.js/blob/acec51c86d8b132bc8779f95eb686cddfb20ac9a/src/authorize.js#L50
redirectUri evaluates to "file:///android_asset/www/index.html#/app/cloud" in this case, so the regex used here fails to match anything. I imagine there will be similar errors on other Cordova platforms, but I don't really have any other devices to test with at the moment.