MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
269 stars 238 forks source link

Crash during redirect after logout is successfull #459

Closed rajath-1990 closed 7 months ago

rajath-1990 commented 8 months ago

I am using this library for authorization app Azure AD. Login is working fine. App is crashing after logout. Crash is happening when it redirects back to the app.

_postLogoutRedirectUrl will be a normal website URL that has been verified by uploading asset_link.json in the server (This is required for app linking)

Please help me in fixing this.

Here is the code:

await _appAuth.endSession(EndSessionRequest(
      idTokenHint: _idToken,
      postLogoutRedirectUrl: _postLogoutRedirectUrl,
      serviceConfiguration: _serviceConfiguration));

Crash: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) E/AndroidRuntime( 4223): Caused by: java.lang.NullPointerException: dataIntent must not be null E/AndroidRuntime( 4223): at net.openid.appauth.Preconditions.checkNotNull(Preconditions.java:55) E/AndroidRuntime( 4223): at net.openid.appauth.EndSessionResponse.fromIntent(EndSessionResponse.java

android manifest:

MaikuB commented 7 months ago

Not able to help you with this as I've not seen this issue myself and the stack trace would indicate it is triggered from the AppAuth Android SDK that this plugin uses. Majority of the logic provided by the plugin is done by the SDKs that it depends on and are maintained by others. You may have this debug this one further yourself, ask others in the community (e.g. on Stack Overflow, Slack etc) and/or see if others have mentioned this issue on the GitHub repository for the AppAuth Android SDK. Closing as it's not something that could be addressed by the plugin

TatyanaRTB commented 6 months ago

Crash can be reproduced in Flutter apps on Android devices.

Here is code example:

try {
  final logoutResult = await _appAuth.endSession(
    EndSessionRequest(
      idTokenHint: idToken,
      postLogoutRedirectUrl: logoutRedirectUrl,
      serviceConfiguration: AuthorizationServiceConfiguration(
        authorizationEndpoint: keycloakAuthEndpoint,
        tokenEndpoint: keycloakTokenEndpoint,
        endSessionEndpoint: keycloakLogoutEndpoint,
      ),
    ),
  );
  final isLogoutSuccessful = logoutResult != null;
  if (isLogoutSuccessful) {
    await _clearSession();
  }
  return isLogoutSuccessful;
} on PlatformException catch (e, stackTrace) {
  return false;
}

Steps to reproduce:

The same issue happened in login process before and error can be handled: https://github.com/MaikuB/flutter_appauth/pull/146

Please check the log attached. log_logout_crash.txt

JohnKim7 commented 5 months ago

Check this PR please: https://github.com/MaikuB/flutter_appauth/pull/468