okta-sdk-appauth-android icon indicating copy to clipboard operation
okta-sdk-appauth-android copied to clipboard

java.lang.IllegalArgumentException: Malformed intent android.app.ActivityThread.performLaunchActivity

Open robinthuan opened this issue 5 years ago • 2 comments

Hi everyone ,I am implement Authorization with okta in fragment android

mOktaAppAuth=OktaAppAuth.getInstance(context);

try {
             mOktaAppAuth?.init(
                        activity,
                        object : OktaAppAuth.OktaAuthListener {
                            override fun onSuccess() {
                                activity?.runOnUiThread { startAuth() }
                            }

                            override fun onTokenFailure(ex: AuthorizationException) {

                            }
                        })
            } catch (ex: AuthorizationException) {
               
            }  
private fun startAuth() {
       if (activity != null) {
           val completionIntent = Intent(activity, WaitingActivity::class.java)
           val cancelIntent = Intent(activity, LoginActivity::class.java)
           completionIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
           try {
               mOktaAppAuth?.login(
                       activity,
                       PendingIntent.getActivity(activity, 0, completionIntent, 0),
                       PendingIntent.getActivity(activity, 0, cancelIntent, 0))
           } catch (ex: AuthorizationException) {
               
           }
       }
   }

And sometime my app is crash with status is Caused by java.lang.IllegalArgumentException Malformed intent net.openid.appauth.AuthorizationManagementResponse.fromIntent (AuthorizationManagementResponse.java:61) com.okta.appauth.android.OktaManagementActivity.onStart (OktaManagementActivity.java:126)| I found function in class AuthorizationManagementResponse write

public static AuthorizationManagementResponse fromIntent(@NonNull Intent dataIntent) {
        if (EndSessionResponse.containsEndSessionResoponse(dataIntent)) {
            return EndSessionResponse.fromIntent(dataIntent);
        } else if (AuthorizationResponse.containEndSessionResoponse(dataIntent)) {
            return AuthorizationResponse.fromIntent(dataIntent);
        } else {
            throw new IllegalArgumentException("Malformed intent");
        }
    }

Anyone help me fix this issues?thanks

robinthuan avatar Sep 25 '19 05:09 robinthuan

Try changing Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK to FLAG_ACTIVITY_CLEAR_TOP. This repository is not maintained. Please use https://github.com/okta/okta-oidc-android

FeiChen-okta avatar Sep 25 '19 16:09 FeiChen-okta

thank @FeiChen-okta I will try it

robinthuan avatar Sep 26 '19 08:09 robinthuan