MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
273 stars 246 forks source link

PlatformException(null_intent, Failed to authorize: Null intent received, null, null) #440

Closed MartinAKovachev closed 1 year ago

MartinAKovachev commented 1 year ago

@MaikuB We continue receiving a huge amount of PlatformException(null_intent, Failed to authorize: Null intent received, null, null) on android devices using flutter_appauth: ^6.0.0 and previous versions. We can't find the exact reason, but from the documentation it states:

If the user presses the back button or closes the browser tab, the launched activity will call Activity#setResult with Activity#RESULT_CANCELED without a data Intent.

https://javadoc.io/doc/net.openid/appauth/0.7.0/net/openid/appauth/AuthorizationService.html#getAuthorizationRequestIntent-net.openid.appauth.AuthorizationRequest-

And we saw in the code, if the intent is null you return that error.

onActivityResult

Could that be the reason for the error (in reality if we try to close the custom tab, we do not receive this type of error so it means the intent is not null)? We can't reproduce the exception locally, only appearing in analytics.

MartinAKovachev commented 1 year ago

https://github.com/MaikuB/flutter_appauth/issues/252

MartinAKovachev commented 1 year ago

Part of our code with fake values:

final authResponse = await const FlutterAppAuth().authorize(
          AuthorizationRequest(
            'clientId',
            'redirectUrl',
            preferEphemeralSession: true,
            additionalParameters: {'key': 'value'},
            serviceConfiguration: AuthorizationServiceConfiguration(
              authorizationEndpoint: 'authorizationEndpoint',
              tokenEndpoint: 'tokenEndpoint',
            ),
          ),
        )
MartinAKovachev commented 1 year ago

The issue was reproduced by following these steps:

  1. Open the app on Android device
  2. Press login button
  3. Press home button (minimise the app)
  4. Open the app again from the icon
  5. Then PlatformException(null_intent, Failed to authorize: Null intent received, null, null)
nblum37 commented 1 year ago

@MartinAKovachev how did you solve the issue?

ManuelRauber commented 12 months ago

I also receive this, same way as @MartinAKovachev described, but without step 3 and 4. I just get it for regular logins.

Not sure where to look here.

marinat commented 3 months ago

in my case I used wrong redirectUri, i used app://callback instead of app:/callback