capacitor-community / generic-oauth2

Generic Capacitor OAuth 2 client plugin. Stop the war in Ukraine!
MIT License
234 stars 115 forks source link

Android crash with NullPointerException #55

Closed masimplo closed 4 years ago

masimplo commented 5 years ago

In google console I see a handful of crashes with the following stacktrace attached

Caused by: java.lang.NullPointerException: 

  at com.byteowls.capacitor.oauth2.OAuth2ClientPlugin.handleOnActivityResult (OAuth2ClientPlugin.java:224)
  at com.getcapacitor.Bridge.onActivityResult (Bridge.java:748)
  at com.getcapacitor.BridgeActivity.onActivityResult (BridgeActivity.java:209)
  at android.app.Activity.dispatchActivityResult (Activity.java:7634)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4622)

Any idea what might be causing this?

Using version 1.0.1 with the following invocation:

return from(Plugins.OAuth2Client.authenticate(
      {
        appId: this._appConfig.thirdPartyAPIs.googleOAuth.clientId.web,
        authorizationBaseUrl: 'https://accounts.google.com/o/oauth2/auth',
        accessTokenEndpoint: 'https://www.googleapis.com/oauth2/v4/token',
        scope: 'email profile',
        resourceUrl: 'https://www.googleapis.com/userinfo/v2/me',
        web: {
          redirectUrl: 'http://localhost:4200',
          windowOptions: 'height=600,left=0,top=0'
        },
        android: {
          appId: this._appConfig.thirdPartyAPIs.googleOAuth.clientId.android,
          responseType: 'code', 
          customScheme: 'com.myapp.android:/'
        },
        ios: {
          appId: this._appConfig.thirdPartyAPIs.googleOAuth.clientId.ios,
          responseType: 'code', 
          customScheme: 'com.myapp.myapp:/'
        }
      }
    )
moberwasserlechner commented 5 years ago

Hi,

the config you use is the same I have, so I have no idea why this breaks for you.

Could you plz share some version information

thx

masimplo commented 5 years ago

Hi,

thanks for looking into this. Capacitor 1.2.1

Devices:

HUAWEI Y5 2018 (HWDRA-MG) | 11 | 64.7%
CPH1853 (CPH1853) | 2 | 11.8%
HUAWEI Y5 Prime 2018 (HWDRA-M) | 1 | 5.9%
A3s (CPH1803) | 1 | 5.9%
Z61 (Z61) | 1 | 5.9%
Redmi 6A (cactus) | 1 | 5.9%

All running Android 8.1 (API Level 27)