VictorAlbertos / RxSocialConnect-Android

OAuth RxJava extension for Android.
Apache License 2.0
257 stars 22 forks source link

Disk caching does not work #28

Open wispborne opened 7 years ago

wispborne commented 7 years ago

To reproduce, simply run the demo app. Sign in to any service (I'm using oauth 1 and twitter, haven't tried oauth 2) and get a valid token.

Now, quit the app entirely, reopen it, and try to get the token.

It won't work - something seems to be going wrong with the encryption/decryption but I don't know what. Unit tests are all passing. Tested on both emulator and real device.

cc @miguelbcr

wispborne commented 7 years ago

This was broken by the encryption commit (3e9bcffab9ddcad003c8dca63b7eb2090d52c516).

That is, it worked in the commit directly prior (2158888a05de9b65a3c212c3ed394475cf73c4b2) and it does not work immediately after.

So clearly, something is wrong with the encryption, either that or we're all using it wrong. I'll keep looking into it but it's not my forte.

wispborne commented 7 years ago

I've implemented a workaround for myself by simply modifying the library to use Hawk instead of the current encryption solution, but it increases the lib from 15kb to 50kb and, of course, adds a 3rd-party dependency.

I'll leave the decision on what to do to the author. For me, the problem is fixed, but the issue with the library remains so I'll leave this issue open.

I wish that I could have come with news on how to fix it but it's beyond my understanding and not something I want to cock up. I'd be happy to provide my 'solution' code if desired; I literally just replaced all of the homebrewed encryption in the Disk class with calls to Hawk, it was super easy.

jbmlaird commented 7 years ago

+1.

Perhaps in the meantime provide a single parameter constructor to not use encryption? I tried supply an empty String and cache still doesn't work.

Could you share your code @davidwhitman ? I'm not familiar with encryption libraries.

wispborne commented 7 years ago

So this is a little embarrassing, but I switched distros and I'm not sure what I did what that code. I ditched the project I needed this library for shortly after posting, on account of the Goodreads API being total shit.

However, there's a compiled .aar of my modified lib here: https://github.com/davidwhitman/Tir/tree/master/RxSocialConnect-HawkEncryption that you're of course free to use. My changes were very basic, you don't need to know really anything about encryption. I just found where RxSocialConnect calls the non-working encryption and I replaced it with the Hawk encryption, swapping one method for another pretty much.

...was that really less than a month ago? Damn.

jbmlaird commented 7 years ago

Can't say I'm surprised about GoodReads. I think they still have a bug where it says you've read a book twice when you enter in a single finish date :/ Been there for at least 2 months

Thanks for that, appreciated.

dbourreau commented 7 years ago

Hi there!

I just made a simple correction in the encryption mechanism. The token disk caching is working again for me with this correction but I'll let @VictorAlbertos or @miguelbcr judge if it's the best way to do it... 😊

VictorAlbertos commented 7 years ago

Thanks @dimitribourreau ;) @miguelbcr can you take a look please, you were the one who implemented this functionality ;)