fullstackreact / react-native-oauth

A react-native wrapper for social authentication login for both Android and iOS
https://fullstackreact.com
MIT License
801 stars 214 forks source link

Android: Upgrade scribejava-apis dependency #149

Open octohedron opened 7 years ago

octohedron commented 7 years ago

My app is crashing with a custom provider, it shouldn't though because it follows the spec.

It's mostly happening because of issues solved in newer versions of the scribejava-apis dependency, have you considered upgrading?

Call stack

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
    Process: com.myapp, PID: 3679
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:325)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
     Caused by: com.github.scribejava.core.exceptions.OAuthException: Response body is incorrect. Can't extract a '"error"\s*:\s*"(\S*?)"' from this: 'The requested resource could not be found.'
        at com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor.extractParameter(OAuth2AccessTokenJsonExtractor.java:97)
        at com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor.generateError(OAuth2AccessTokenJsonExtractor.java:55)
        at com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor.extract(OAuth2AccessTokenJsonExtractor.java:46)
        at com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor.extract(OAuth2AccessTokenJsonExtractor.java:16)
        at com.github.scribejava.core.oauth.OAuth20Service.sendAccessTokenRequestSync(OAuth20Service.java:37)
        at com.github.scribejava.core.oauth.OAuth20Service.getAccessToken(OAuth20Service.java:56)
        at io.fullstack.oauth.OAuthManagerFragmentController$Load2AccessTokenTask.doInBackground(OAuthManagerFragmentController.java:364)
        at io.fullstack.oauth.OAuthManagerFragmentController$Load2AccessTokenTask.doInBackground(OAuthManagerFragmentController.java:348)
        at android.os.AsyncTask$2.call(AsyncTask.java:305)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:761) 

This is crashing my Android application, as you can see it cannot parse a response that doesn't follow the '"error"\s*:\s*"(\S*?)"' format.

Apparently the cause is that it's making a GET request to the /token endpoint instead of a POST request as specified in the oauth 2.0 spec.

Is there a way to change this to a POST request without having to fork and upgrade etc?

appfr3d commented 6 years ago

Experiencing the same problem, did you find a way to solve it?

octohedron commented 6 years ago

@appfr3d Actually, yes I did solve it, solution was to fork this whole project and rewrite most of it, also had to fork the scribejava dependencies and change a lot of the code there in all their submodules, and it's not even a gradle project, so good luck with that.

Unfortunately, I don't own the code I wrote so I cannot share it, but consider you will have to spend quite a bit of time debugging and developing fixes for this, since you'll need to learn what the code does and where it's failing, then write the new implementations, etc.