react-native-oauth icon indicating copy to clipboard operation
react-native-oauth copied to clipboard

Native null pointer exception for JIRA provider (Java).

Open TeunKooijman opened this issue 6 years ago • 3 comments

When trying to add a provider for JIRA OAuth 1.0, the native Java code crashes on a Null Pointer Exception on oauth10aService.getRequestToken() (line 240 in OAuthManagerFragmentController$LoadRequestTokenTask).

The stack trace is as follows:

java.lang.RuntimeException: An error occurred while executing doInBackground()
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at android.os.AsyncTask$3.done(AsyncTask.java:318)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:762)
11-06 15:49:40.158 25802 25951 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.github.scribejava.core.model.OAuth1RequestToken com.github.scribejava.core.oauth.OAuth10aService.getRequestToken()' on a null object reference
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at io.fullstack.oauth.OAuthManagerFragmentController$LoadRequestTokenTask.doInBackground(OAuthManagerFragmentController.java:240)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at io.fullstack.oauth.OAuthManagerFragmentController$LoadRequestTokenTask.doInBackground(OAuthManagerFragmentController.java:226)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at android.os.AsyncTask$2.call(AsyncTask.java:304)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-06 15:49:40.158 25802 25951 E AndroidRuntime:        ... 4 more

The provider is added and configured as follows:

     this.manager = new OAuthManager("My-App-Name");
     this.manager.addProvider({
            jira: 
            {
                auth_version: '1.0',
                authorize_url: 'https://my-hosted-jira-name.atlassian.net/plugins/servlet/oauth/authorize',
                access_token_url: 'https://my-hosted-jira-name.atlassian.net/plugins/servlet/oauth/access-token',
                request_token_url: "https://my-hosted-jira-name.atlassian.net/plugins/servlet/oauth/request-token",
                callback_url: () => "http://localhost/jira",
                api_url: 'https://my-hosted-jira-name.atlassian.net/rest/api/2',
            }
        })
        this.manager.configure({
            jira: {
                client_id: 'My Consumer Key',
                client_secret: 'my-secret-private-key-that-I-removed-for-security'
            }
        });

And then the authorization is kicked-off by calling:

    authorize = async () =>
    {
        try
        {
            const response = await this.manager.authorize('jira');
            console.log("RESPONSE: " + JSON.stringify(response));
        }
        catch(e)
        {
            console.log("ERROR: " + JSON.stringify(e));
        }
    }

Any help trying to figure out what is going on is greatly appreciated, so thanks in advance!

TeunKooijman avatar Nov 06 '18 15:11 TeunKooijman

Upon closer inspection the problem seems to be in the static public OAuth10aService getApiFor10aProvider() method in OAuthManagerProviders.java on line 42. Where getApiFor20Provider() actually has a fall through leading to returning a call to OAuthManagerProviders.configurableService(), the 1.0a version falls through to returning null instead.

Was this intentional? If not, is there any chance this could be fixed soon?

The screenshot below shows exactly what I mean:

image

TeunKooijman avatar Nov 08 '18 09:11 TeunKooijman

@TeunKooijman did you solve this issue.?

ahmedtehseen avatar Jun 11 '19 11:06 ahmedtehseen

I'm having same problem with facebook provider.

ahmedtehseen avatar Jun 11 '19 11:06 ahmedtehseen