Flutter_appauth doesn't redirect to app

I’m using flutter_appauth library for implementing oauth2 with custom web service.

Problem:
When the user signs in, in a clear browser without cache, cookies etc. (meaning that there are no active session in it), it doesn’t redirect the user to the app. However, when the browser already has an active session (user can obtain it if he provides correct credentials and then exits the browser) redirection works perfectly fine.

So basically this is the flow for better understanding:

  1. User enters the app
  2. Clicks on sign in button
  3. Provides correct credentials (browser doesn’t redirect)
  4. Exits the browser
  5. Clicks sign in button again
  6. This time redirection works without asking for credentials (because the browser already has active session in it)

This is the code

Login

final AuthorizationTokenResponse result =
          await appAuth.authorizeAndExchangeCode(
        AuthorizationTokenRequest(
          Constants.oauth2ClientId,
          'com.myapp.app:/oauthredirect',
          serviceConfiguration: AuthorizationServiceConfiguration(
            authorizationEndpoint: API.oauth2authorize().toString(),
            tokenEndpoint: API.oauth2token().toString(),
          ),
          preferEphemeralSession: true,
          scopes: [
            'read',
            'write',
          ],
          allowInsecureConnections: true,
        ),
      );

build.gradle

manifestPlaceholders += [appAuthRedirectScheme: 'com.myapp.app']

I’ve already checked if redirect schemes are similar with the backend and everything is fine.

would be helpful to know on which platform this happens. Web or where else

1 Like

It happens on android