flutterkeycloakappauth

Flutter appauth Invalid parameter: redirect_uri


I have local instance of keylcoak and I am trying to connect my flutter app to it and for that I am following the this tutorial but I got stuck on this redirect_uri issue.

In android's build.gradle I have added the following piece to default config:

  applicationId = 'com.my.example_app'
  manifestPlaceholders = [
        'appAuthRedirectScheme': 'com.my.example_app'
  ]

In the code I have:

    const REDIRECT_URI = 'com.my.example_app://login-callback';
    //some code in between
    final AuthorizationTokenRequest req = AuthorizationTokenRequest(
    CLIENT_ID,
    REDIRECT_URI,
    allowInsecureConnections: true,
    issuer: ISSUER,
    discoveryUrl: DISCOVERY_URL,
    scopes: SCOPES);
    final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode(req);

I was also trying different configs on keycloak side: enter image description here

So when I press login and it redirects me to the keycloak page but all I see is:

enter image description here

Does anyone know what is the proper redirect uri value here?


Solution

  • The problem with your code is that your applicationId and appAuthRedirectScheme contains '_' character which is invalid for an URL, so I would suggest to change app package name to not contain capitalized or other characters other than '.', and it should work